Example #1
0
    public static void Connect(string host, string username, bool toggleWss)
    {
        print(string.Format("Connecting to server: {0} ...", host));

        WebsocketSharpFactory socketFactory = new WebsocketSharpFactory();

        socket = new Socket(socketFactory, new Socket.Options
        {
            channelRejoinInterval = TimeSpan.FromMilliseconds(200),
            //logger = new BasicLogger()
        });

        socket.OnOpen = () => {
            LobbyChannel.JoinLobby(username);
        };
        socket.OnError = (x) => {
            MenuServerConnect.joinError             = "error_connecting";
            MenuServerConnect.connectedSuccessfully = false;
            MenuServerConnect.connectionDone        = true;
        };
        string socketUrlBase = "ws://{0}/socket";

        if (toggleWss)
        {
            socketUrlBase = "wss://{0}/socket";
        }
        socket.Connect(string.Format(socketUrlBase, host), null);
    }
    // Start is called before the first frame update
    void Start()
    {
        listCreator = list.GetComponent <ListCreator>();

        createButton.onClick.AddListener(() => {
            LobbyChannel.SendCreateGame();
        });
        joinButton.onClick.AddListener(() => {
            LobbyChannel.SendJoinGame(selectedGameId);
        });
    }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        listCreator = list.GetComponent <PlayerListCreator>();

        leaveButton.onClick.AddListener(() => {
            LobbyChannel.SendLeaveGame(game.id);
        });
        readyButton.onClick.AddListener(() => {
            LobbyChannel.SendReadyGame(game.id);
        });
        startButton.onClick.AddListener(() => {
            LobbyChannel.SendStartGame(game.id);
        });
    }
Example #4
0
 public void AddHook(Channels channel, LobbyChannel subChannel, Action <NetIncomingMessage, object> hook, bool oneTime)
 {
     AddHook((int)channel, (int)subChannel, hook, oneTime);
 }
Example #5
0
 public static void SendMessageAndGetResponse(Channels channel, LobbyChannel subChannel, object message, Action <object> response)
 {
     SendMessageAndGetResponse((int)channel, (int)subChannel, message, response);
 }
Example #6
0
 public static void AddHook(Channels channel, LobbyChannel subChannel, Action <object> hook, bool oneTime)
 {
     AddHook((int)channel, (int)subChannel, hook, oneTime);
 }
Example #7
0
 public static void SendMessage(Channels channel, LobbyChannel subChannel, object message, NetDeliveryMethod method)
 {
     SendMessage((int)channel, (int)subChannel, message, method);
 }