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);
        }
Пример #2
0
        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());
        }
Пример #3
0
 public static void Connect()
 {
     //s_network.GetIPAddress();
     s_network.Connect();
 }
Пример #4
0
 public static void Connect()
 {
     s_network.Connect();
 }
Пример #5
0
 public Task Connect(System.Net.IPEndPoint endpoint)
 {
     return(_network.Connect(endpoint));
 }