using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Sfs2X;
using Sfs2X.Entities;
using Sfs2X.Requests;

static class Program
{
    public static SmartFox smartFox;
    public static LobbyForm lobbyForm = new LobbyForm();
    public static string[] roomStrings;

    /// 
    /// メイン エントリ ポイント
    /// 
    [STAThread]
    static void Main() {

        // 1. SmartFoxServer 2X API をインスタンス化
        smartFox = new SmartFox(true);

        // 2. サーバーに接続
        smartFox.Connect("127.0.0.1", 9933);

        // 3. ロビー画面を表示
        Application.Run(lobbyForm);

        // 4. サーバーから切断
        smartFox.Disconnect();
    }

    /// 
    /// ロビー画面表示
    /// 
    public static void ShowLobbyForm() {
        lobbyForm.Show();
    }

    /// 
    /// 画面切り替え
    /// 
    /// 
    public static void ShowForm(Form form) {
        lobbyForm.Hide();
        form.Show();
    }

    /// 
    /// ルームリスト取得
    /// 
    public static void ReadRoomListAndJoin() {
        List roomList = Program.smartFox.RoomManager.GetRoomList();
        List roomNames = new List();
        foreach (Room room in roomList) {
            if (room.IsHidden || room.IsPasswordProtected) {
                continue;
            }
            roomNames.Add(room.Name);
        }
        roomStrings = roomNames.ToArray();

        if (smartFox.LastJoinedRoom == null && Program.smartFox.RoomList.Count > 0) {
            JoinRoom(smartFox.RoomList[0].Name);
        }
    }

    /// 
    /// ルーム処理
    /// 
    /// 
    public static void JoinRoom(string roomName) {
        if (smartFox.LastJoinedRoom == null)
            smartFox.Send(new JoinRoomRequest(roomName));
        else
            smartFox.Send(new JoinRoomRequest(roomName, "", smartFox.LastJoinedRoom.Id));
    }
}
inserted by FC2 system