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); }); }
// 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); }); }
public void AddHook(Channels channel, LobbyChannel subChannel, Action <NetIncomingMessage, object> hook, bool oneTime) { AddHook((int)channel, (int)subChannel, hook, oneTime); }
public static void SendMessageAndGetResponse(Channels channel, LobbyChannel subChannel, object message, Action <object> response) { SendMessageAndGetResponse((int)channel, (int)subChannel, message, response); }
public static void AddHook(Channels channel, LobbyChannel subChannel, Action <object> hook, bool oneTime) { AddHook((int)channel, (int)subChannel, hook, oneTime); }
public static void SendMessage(Channels channel, LobbyChannel subChannel, object message, NetDeliveryMethod method) { SendMessage((int)channel, (int)subChannel, message, method); }