public async Task Connect(NetworkConnectionConfig config) { if (connectionTask != null) { await connectionTask.Task; return; } connectionTask = new TaskCompletionSource <object>(); Debug.Log("Start connection"); Connection = await NetworkInterface.Connect(config); Debug.Log("Connection complete!"); InitConnection(Connection); }
public async Task Connect(string ip, uint port) { if (connectionTask != null) { await connectionTask.Task; return; } connectionTask = new TaskCompletionSource <object>(); ServerConnection = await NetworkInterface.Connect(ip, (int)port); var handlers = ServerConnection.MessageHandlers; handlers.RegisterHandler <InputSetMessage>(MessageCodes.UpdateInput, OnGetInput); handlers.RegisterHandler <ServerStateMessage>(MessageCodes.UpdateState, OnGetState); handlers.RegisterHandler <MatchStartMessage>(MessageCodes.MatchStart, OnStartMatch); handlers.RegisterHandler <MatchFinishMessage>(MessageCodes.MatchFinish, OnFinishMatch); handlers.RegisterHandler <ServerUpdateConfigMessage>(MessageCodes.UpdateConfig, OnUpdateConfig); handlers.RegisterHandler <PeerReadyMessage>(MessageCodes.ServerReady, OnSetServerReady); connectionTask.TrySetResult(new object()); }
public static void Connect() { //s_network.GetIPAddress(); s_network.Connect(); }
public static void Connect() { s_network.Connect(); }
public Task Connect(System.Net.IPEndPoint endpoint) { return(_network.Connect(endpoint)); }