示例#1
0
        internal static Promise AcceptConnection(InProcClientNetworkProvider inProcClient, ServerInfo serverInfo)
        {
            var d = Deferred.Create();

            try
            {
                var server = servers[serverInfo.Server + ":" + serverInfo.Port];
                if (server.allowNewConnections)
                {
                    server.inProcClients.Add(inProcClient.ClientId, inProcClient);
                    server.ClientConnected.Fire(new MultiPlayerClientConnection()
                    {
                        ClientId = inProcClient.ClientId
                    });
                }
                else
                {
                    throw new IOException("new connections not allowed");
                }
                d.Resolve();
            }
            catch (Exception ex)
            {
                d.Reject(ex);
            }
            return(d.Promise);
        }
示例#2
0
        internal static Task AcceptConnection(InProcClientNetworkProvider inProcClient, ServerInfo serverInfo)
        {
            var d = new TaskCompletionSource <bool>();

            try
            {
                var server = servers[serverInfo.Server + ":" + serverInfo.Port];
                if (server.allowNewConnections)
                {
                    server.inProcClients.Add(inProcClient.ClientId, inProcClient);
                    server.ClientConnected.Fire(new MultiPlayerClientConnection()
                    {
                        ClientId = inProcClient.ClientId
                    });
                }
                else
                {
                    throw new IOException("new connections not allowed");
                }
                d.SetResult(true);
            }
            catch (Exception ex)
            {
                d.SetException(ex);
            }
            return(d.Task);
        }