示例#1
0
 public void EstablishTunnel(string host, int port, string httpVersion, INetworkConnection client)
 {
     Contract.Requires(client != null);
     Contract.Requires(port > 0);
     Contract.Requires(!string.IsNullOrEmpty(host));
     Contract.Requires(!string.IsNullOrEmpty(httpVersion));
 }
示例#2
0
        public void EstablishTunnel( string host, int port, string httpVersion, INetworkConnection client )
        {
            _client = client;
            _httpVersion = httpVersion;

            _factory.BeginConnect(host, port, HandleConnect );
        }
 public SimplexAsyncTransitStrategy(INetworkConnection con)
 {
     m_OwningConnection = con;
     LastUDPACKReceived = DateTime.MinValue;
     m_TCPSockState = new SockState(null, 0, null);
     m_TCPSockState.AsyncEventArgs = new SocketAsyncEventArgs();
 }
        public ConnectionManager(ILogger logger,
            ICredentialProvider credentialProvider,
            INetworkConnection networkConnectivity,
            IServerLocator serverDiscovery,
            string applicationName,
            string applicationVersion,
            IDevice device,
            ClientCapabilities clientCapabilities,
            ICryptographyProvider cryptographyProvider,
            Func<IClientWebSocket> webSocketFactory = null,
            ILocalAssetManager localAssetManager = null)
        {
            _credentialProvider = credentialProvider;
            _networkConnectivity = networkConnectivity;
            _logger = logger;
            _serverDiscovery = serverDiscovery;
            _httpClient = AsyncHttpClientFactory.Create(logger);
            ClientCapabilities = clientCapabilities;
            _webSocketFactory = webSocketFactory;
            _cryptographyProvider = cryptographyProvider;
            _localAssetManager = localAssetManager;

            Device = device;
            ApplicationVersion = applicationVersion;
            ApplicationName = applicationName;
            ApiClients = new Dictionary<string, IApiClient>(StringComparer.OrdinalIgnoreCase);
            SaveLocalCredentials = true;

            Device.ResumeFromSleep += Device_ResumeFromSleep;

            var jsonSerializer = new NewtonsoftJsonSerializer();
            _connectService = new ConnectService(jsonSerializer, _logger, _httpClient, _cryptographyProvider, applicationName, applicationVersion);
        }
示例#5
0
        protected override void OnCharacterHandoffComplete(INetworkConnection con, ServerCharacterInfo character, Guid owner)
        {
            base.OnCharacterHandoffComplete(con, character, owner);
            OutboundServerConnection ocon = con as OutboundServerConnection;

            // we uncache a character when they disconnect (even as part of a transfer, just in case they never reconnect).
            // now that they have reconnected, recache them.
            CharacterCache.CacheCharacter(character, ocon.ServerUserID, TimeSpan.MaxValue);
        }
 public void OnPlayerLeaveGame(INetworkConnection sender, Packet gmsg)
 {
     PacketGenericMessage msg = gmsg as PacketGenericMessage;
     GameServerGame g = ServerUser.CurrentCharacter.GetCurrentGame();
     if (g != null)
     {
         g.RemovePlayer(ServerUser.CurrentCharacter, "left the game.", true);
         g.RemoveObserver(ServerUser.CurrentCharacter);
     }
 }
        private void OnPatchInfoRequest(INetworkConnection con, Packet r)
        {
            PropertyBag bag = new PropertyBag();
            bag.SetProperty("MB", ((PatchServerProcess)MyServer).MBytesPatchDataSent);
            bag.SetProperty("Num", ((PatchServerProcess)MyServer).PatchFileSent);
            bag.SetProperty("Users", ConnectionManager.ConnectionCount);

            PacketGenericMessage msg = r as PacketGenericMessage;
            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms = bag;
        }
示例#8
0
 /// <summary>
 /// Phase 1: Player requests login to the system.  This method attempts to authenticate the player (or create a new account, depending on method parms)
 /// </summary>
 public void OnPlayerLoginRequest(INetworkConnection con, Packet pMsg)
 {
     if (!MyServer.RequireAuthentication)
     {
         DoNoAuthLogin(con, pMsg);
     }
     else
     {
         DoDatabaseLogin(con, pMsg);
     }
 }
示例#9
0
        public HttpServer( INetworkConnection connection, IHttpResponseFilter responseFilter )
        {
            Contract.Requires( connection != null );

            _responseFilter = responseFilter;
            _connection = connection;

            connection.ConnectionClosed += ConnectionConnectionClosed;
            connection.Shutdown += ConnectionConnectionClosed;
            connection.DataAvailable += ConnectionDataAvailable;

            _parser = new HttpStreamParser();
            _parser.ReadResponseHeaderComplete += ParserReadResponseHeaderComplete;
        }
示例#10
0
        private void HandleConnect(bool success, INetworkConnection server)
        {
            try
            {
                if (success)
                {
                    ServiceLog.Logger.Info("Established HTTPS tunnel");

                    _server = server;

                    _server.DataAvailable += new EventHandler<DataAvailableEventArgs>(_server_DataAvailable);
                    _server.ConnectionClosed += new EventHandler(_client_ConnectionClosed);
                    _server.Shutdown += new EventHandler(_client_ConnectionClosed);
                    _server.Start();

                    _client.ConnectionClosed += new EventHandler(_client_ConnectionClosed);
                    _client.Shutdown += new EventHandler(_client_ConnectionClosed);
                    _client.DataAvailable += new EventHandler<DataAvailableEventArgs>(_client_DataAvailable );

                    _client.SendData( Encoding.UTF8.GetBytes( string.Format(
                        "HTTP/{0} 200 Connection established\r\n" +
                        "Proxy-agent: Gallatin-Proxy/1.1\r\n\r\n",
                        _httpVersion ) ) );

                }
                else
                {
                    ServiceLog.Logger.Warning("Unable to establish HTTPS tunnel");
                    OnTunnelClosed();
                }
            }
            catch ( Exception ex )
            {
                ServiceLog.Logger.Exception("Unhandled exception while trying to connect to HTTPS host", ex);
                OnTunnelClosed();
            }
        }
示例#11
0
        protected override void OnRemoteCharacterDisconnected(INetworkConnection con, int characterId, string transferTarget)
        {
            // there is a remote possibility that the player can reconnect to THIS server (as part of a transfer)
            // BEFORE the content server's disconnection message arives (which calls this method).  In such a case,
            // the character would become uncached (i.e. the player connecting causes the character to be re-cached
            // and then when this disconnection packet arrives, it would uncache the character.

            base.OnRemoteCharacterDisconnected(con, characterId, transferTarget);
            // uncache, if appropriate
            if (!CharacterCache.IsCharacterConnectionAlive(characterId))
            {
                if (transferTarget != null && transferTarget.Length > 0)
                {
                    // just transferring, so don't immediately expire the cache.  let it expire if the player never makes it on again.
                    // if the player logs back in on another server, we will have OnCharacterHandoffComplete fire, which will reset the
                    // cache timer
                    CharacterCache.UpdateCacheTime(characterId, TimeSpan.FromSeconds(60));
                }
                else
                {
                    CharacterCache.UncacheCharacter(characterId);
                }
            }
        }
 /// <summary>
 /// Gets called when we get a listing of characters on this cluster.  This only happens if the server is configured to use Characters.  If the server
 /// does not use characters, this message will never arrive.  If it does, we need to pick a character (or create a new one and then pick one) before
 /// central server will let us get to any of the content on the server.
 /// </summary>
 /// <param name="con"></param>
 /// <param name="p"></param>
 protected virtual void OnCharacterListingReceived(INetworkConnection con, Packet p)
 {
     PacketCharacterListing msg = p as PacketCharacterListing;
     Characters.Clear();
     for(int i = 0; i < msg.Characters.Count; i++)
     {
         Characters.Add(msg.Characters[i] as CharacterInfo);
     }
     FireCharacterListingArrived(this, EventArgs.Empty);
 }
 public override bool OnCheckObserver(INetworkConnection conn)
 {
     ++called;
     return(true);
 }
        public IEnumerator Setup() => UniTask.ToCoroutine(async() =>
        {
            serverGo      = new GameObject("server", typeof(NetworkSceneManager), typeof(ServerObjectManager), typeof(NetworkServer));
            clientGo      = new GameObject("client", typeof(NetworkSceneManager), typeof(ClientObjectManager), typeof(NetworkClient));
            testTransport = serverGo.AddComponent <LoopbackTransport>();

            await UniTask.Delay(1);

            server = serverGo.GetComponent <NetworkServer>();
            client = clientGo.GetComponent <NetworkClient>();

            server.transport = testTransport;
            client.Transport = testTransport;

            serverSceneManager        = serverGo.GetComponent <NetworkSceneManager>();
            clientSceneManager        = clientGo.GetComponent <NetworkSceneManager>();
            serverSceneManager.server = server;
            clientSceneManager.client = client;
            serverSceneManager.Start();
            clientSceneManager.Start();

            serverObjectManager        = serverGo.GetComponent <ServerObjectManager>();
            serverObjectManager.server = server;
            serverObjectManager.networkSceneManager = serverSceneManager;
            serverObjectManager.Start();

            clientObjectManager        = clientGo.GetComponent <ClientObjectManager>();
            clientObjectManager.client = client;
            clientObjectManager.networkSceneManager = clientSceneManager;
            clientObjectManager.Start();

            ExtraSetup();

            // create and register a prefab
            playerPrefab             = new GameObject("serverPlayer", typeof(NetworkIdentity), typeof(T));
            NetworkIdentity identity = playerPrefab.GetComponent <NetworkIdentity>();
            identity.AssetId         = Guid.NewGuid();
            clientObjectManager.RegisterPrefab(identity);

            // wait for client and server to initialize themselves
            await UniTask.Delay(1);

            // start the server
            var started = new UniTaskCompletionSource();
            server.Started.AddListener(() => started.TrySetResult());
            server.ListenAsync().Forget();

            await started.Task;

            var builder = new UriBuilder
            {
                Host   = "localhost",
                Scheme = client.Transport.Scheme.First(),
            };

            // now start the client
            await client.ConnectAsync(builder.Uri);

            await AsyncUtil.WaitUntilWithTimeout(() => server.connections.Count > 0);

            // get the connections so that we can spawn players
            connectionToClient = server.connections.First();
            connectionToServer = client.Connection;

            // create a player object in the server
            serverPlayerGO  = Object.Instantiate(playerPrefab);
            serverIdentity  = serverPlayerGO.GetComponent <NetworkIdentity>();
            serverComponent = serverPlayerGO.GetComponent <T>();
            serverObjectManager.AddPlayerForConnection(connectionToClient, serverPlayerGO);

            // wait for client to spawn it
            await AsyncUtil.WaitUntilWithTimeout(() => connectionToServer.Identity != null);

            clientIdentity  = connectionToServer.Identity;
            clientPlayerGO  = clientIdentity.gameObject;
            clientComponent = clientPlayerGO.GetComponent <T>();
        });
示例#15
0
        internal void ClientNotReadyMessage(INetworkConnection conn, NotReadyMessage msg)
        {
            logger.Log("NetworkSceneManager.OnClientNotReadyMessageInternal");

            Client.Connection.IsReady = false;
        }
示例#16
0
		internal NetworkConnection(INetworkConnection networkConnection) {
			this.networkConnection = networkConnection;
		}
示例#17
0
        private void OnCharacterSelectRequest(INetworkConnection con, Packet mesg)
        {
            PacketGenericMessage genMsg = mesg as PacketGenericMessage;
            string msg = "";
            ReplyType rslt = ReplyType.OK;
            int id = genMsg.Parms.GetIntProperty((int)PropertyID.CharacterId).GetValueOrDefault(-1);
            ServerCharacterInfo ci = null;

            // if we don't use characters, there wont be one in the DB
            if (MyServer.UseCharacters)
            {
                ci = CharacterUtil.Instance.LoadCharacter(ServerUser, id, ref msg);
            }

            if (ci == null && ServerUser.CurrentCharacter != null && ServerUser.CurrentCharacter.ID == id)
            {
                ci = ServerUser.CurrentCharacter;
            }

            PacketReply rep = CreateStandardReply(genMsg, rslt, msg);
            //genMsg.ReplyPacket = rep;

            if (ci == null)
            {
                genMsg.ReplyPacket = rep;
                rep.ReplyCode = ReplyType.Failure;
                rep.ReplyMessage = "Unable to load character.";
                return;
            }

            ServerUser.CurrentCharacter = ci;
            CharacterCache.CacheCharacter(ci, MyServer.ServerUserID, TimeSpan.MaxValue);

            rep.Parms.SetProperty((int)PropertyID.CharacterInfo, ci.CharacterInfo as IComponent);

            Send(rep); // reply needs to arrive before the OnSelected event is fired, in case OnSelected results in a server transfer
            OnCharacterSelected(ci);
        }
示例#18
0
 protected BaseLocalPlayer(INetworkConnection network, IAsyncHttpClient httpClient)
 {
     Network = network;
     HttpClient = httpClient;
     network.NetworkChanged += network_NetworkChanged;
 }
 /// <summary>
 /// Callback used by the visibility system to determine if an observer (player) can see this object.
 /// <para>If this function returns true, the network connection will be added as an observer.</para>
 /// </summary>
 /// <param name="conn">Network connection of a player.</param>
 /// <returns>True if the player can see this object.</returns>
 public abstract bool OnCheckObserver(INetworkConnection conn);
        protected override void OnConnected(INetworkConnection connection)
        {
            base.OnConnected(connection);

            compositionManager.ResetOnNewCameraConnection();
        }
示例#21
0
 public void AddConnection(INetworkConnection connection)
 {
     connections.Add(connection);
 }
示例#22
0
 void CmdFunction(int someNumber, NetworkIdentity someTarget, INetworkConnection connection = null)
 {
     // do something
 }
        protected virtual void OnConnected(INetworkConnection connection)
        {
            currentConnection = connection;

            NotifyConnected(connection);
        }
示例#24
0
 public void ClientConnRpcTest(INetworkConnection conn, int arg1, string arg2)
 {
     this.targetRpcConn = conn;
     this.targetRpcArg1 = arg1;
     this.targetRpcArg2 = arg2;
 }
        protected virtual void OnQuickMatchResult(INetworkConnection con, Packet p)
        {
            PacketQuickMatchResult res = p as PacketQuickMatchResult;

            FireQuickMatchResultArrived(res.ReplyCode == ReplyType.OK, res.ReplyMessage, this, res.TheGame);
        }
 protected virtual void OnRequestSelectCharacterReply(INetworkConnection con, Packet reply)
 {
     PacketReply p = reply as PacketReply;
     if (p.ReplyCode != ReplyType.OK)
     {
         FireSelectCharacterFailed(p.ReplyMessage);
     }
     else if (p.ReplyCode == ReplyType.OK)
     {
         CurrentCharacter = p.Parms.GetComponentProperty((int)PropertyID.CharacterInfo) as CharacterInfo;
         FireCharacterActivated(this, EventArgs.Empty);
     }
 }
示例#27
0
 public bool StartListening(AddressFamily family, int port, int maxSimultaneousListens, INetworkConnection owner)
 {
     m_Owner = owner;
         return StartListening(family, port, ipe => { return m_Owner; });
 }
示例#28
0
 void RegisterServerMessages(INetworkConnection connection)
 {
     connection.RegisterHandler <ReadyMessage>(OnServerReadyMessageInternal);
     connection.RegisterHandler <RemovePlayerMessage>(OnServerRemovePlayerMessageInternal);
 }
示例#29
0
        private void OnCharacterDeleteRequest(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            string rsltMsg = "";
            ReplyType rslt = ReplyType.Failure;
            int characterId = msg.Parms.GetIntProperty((int)PropertyID.CharacterId).GetValueOrDefault();

            if(MyServer.UseCharacters && MyServer.RequireAuthentication && CharacterUtil.Instance.DeleteCharacter(characterId, ServerUser, false, "Player requested deletion from [" + con.RemoteEndPoint.ToString() + "].", ref rsltMsg))
            {
                rslt = ReplyType.OK;
            }

            PacketReply rep = CreateStandardReply(msg, rslt, rsltMsg);
            msg.ReplyPacket = rep;
        }
示例#30
0
 void RegisterClientMessages(INetworkConnection connection)
 {
     connection.RegisterHandler <NotReadyMessage>(OnClientNotReadyMessageInternal);
     connection.RegisterHandler <SceneMessage>(OnClientSceneInternal);
 }
示例#31
0
        /// <summary>
        /// Encryption helper method. 
        /// </summary>
        private void OnRijndaelExchange(INetworkConnection con, Packet pck)
        {
            PacketRijndaelExchange msg = pck as PacketRijndaelExchange;
            try
            {
                m_ConnectionKey = CryptoManager.DecryptRijndaelKey(msg.RijndaelExchangeData);
                PacketLineSecured p = (PacketLineSecured)CreatePacket((int)PacketType.LineSecured, 0, false, true);
                p.Key = CryptoManager.RijEncrypt(m_ConnectionKey, 0, m_ConnectionKey.Length, m_ConnectionKey);
                p.ReplyCode = ReplyType.OK;
                msg.ReplyPacket = p;
                RemoteRsaKey = msg.PublicRSAKey;

            }
            catch (Exception e)
            {
                KillConnection("Encryption key exchange error. Disconnecting client connection. " + e.Message);
            }
        }
示例#32
0
 /// <summary>
 /// Called on the server when a new client connects.
 /// <para>Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.</para>
 /// </summary>
 /// <param name="conn">Connection from client.</param>
 public virtual void OnServerConnect(INetworkConnection conn)
 {
 }
 protected void OnGameStartReply(INetworkConnection con, Packet p)
 {
     PacketReply rep = p as PacketReply;
     if (rep.ReplyCode != ReplyType.OK)
     {
         // only fire this event if it the request fails.
         // if the start request succeeds, then OnGameStarted will fire
         FireGameStartReply(this, false, rep.ReplyMessage);
     }
 }
示例#34
0
 /// <summary>
 /// Called on clients when a servers tells the client it is no longer ready.
 /// <para>This is commonly used when switching scenes.</para>
 /// </summary>
 /// <param name="conn">Connection to the server.</param>
 public virtual void OnClientNotReady(INetworkConnection conn)
 {
 }
示例#35
0
 protected override void OnDisconnected(INetworkConnection connection)
 {
     DebugLog($"Broadcaster received disconnect from {connection.ToString()}");;
     base.OnDisconnected(connection);
 }
示例#36
0
 private void NetworkManagerConnected(INetworkConnection obj)
 {
     SendCalibrationDataAsync();
 }
示例#37
0
 protected virtual bool ShouldUpdateFrame(INetworkConnection connection)
 {
     return(this.enabled);
 }
示例#38
0
 /// <inheritdoc />
 protected virtual bool ShouldSendChanges(INetworkConnection connection)
 {
     return(TransformBroadcaster.ShouldSendTransformInHierarchy(connection));
 }
        private Queue<NetQItem> m_SendQueueUDP = new Queue<NetQItem>(); // packet send queue

        #endregion Fields

        #region Constructors

        public DuplexAsynchTransitStrategy(INetworkConnection con)
        {
            m_OwningConnection = con;
            LastUDPACKReceived = DateTime.MinValue;
        }
示例#40
0
 internal NetworkConnection(INetworkConnection networkConnection)
 {
     this.networkConnection = networkConnection;
 }
 protected virtual void OnRequestDeleteCharacterReply(INetworkConnection con, Packet reply)
 {
     PacketReply p = reply as PacketReply;
     if (p.ReplyCode != ReplyType.OK)
     {
         FireDeleteCharacterFailed(p.ReplyMessage);
     }
     else
     {
         RequestCharacterListing();
     }
 }
示例#42
0
 public void ClientSceneChanged(INetworkConnection conn)
 {
     ClientSceneChangedCalled++;
 }
 private void OnCharacterActivated(INetworkConnection con, Packet gmsg)
 {
     PacketGenericMessage msg = gmsg as PacketGenericMessage;
     CharacterInfo ci = msg.Parms.GetComponentProperty((int)PropertyID.CharacterInfo) as CharacterInfo;
     CurrentCharacter = ci;
     FireCharacterActivated(this, EventArgs.Empty);
 }
示例#44
0
 public void ClientNotReady(INetworkConnection conn)
 {
     ClientNotReadyCalled++;
 }
示例#45
0
        private void HandleClientConnected( INetworkConnection clientConnection )
        {
            try
            {
                //ServiceLog.Logger.Info("ProxyService notified of new client connect. Pool size: {0}", _sessionPool.AvailablePoolSize);

                ISession session = _sessionPool.Get();

                lock (_activeSessions)
                {
                    _activeSessions.Add(session);
                }

                session.SessionEnded += HandleSessionEnded;

                session.Start(clientConnection);
            }
            catch ( InvalidOperationException ex )
            {
                ServiceLog.Logger.Exception(
                    "No more clients can be accepted; the pool of available sessions was exhausted. Increase the pool maximum number of clients in the proxy server settings.",
                    ex );
            }
        }
示例#46
0
 public void OnAuthenticated(INetworkConnection conn)
 {
     Authenticated?.Invoke(conn);
 }
示例#47
0
        private void OnCharacterCreateRequest(INetworkConnection con, Packet gmsg)
        {
            PacketGenericMessage msg = gmsg as PacketGenericMessage;
            string rsltMsg = "";
            ServerCharacterInfo ci = null;

            if(MyServer.UseCharacters)
            {
                ci = CharacterUtil.Instance.CreateNewCharacter(msg.Parms, ServerUser);
            }

            ReplyType rslt = ReplyType.Failure;
            if (ci != null && OnValidateCharacterCreateRequest(ci, ref rsltMsg))
            {
                if (CharacterUtil.Instance.PersistNewCharacter(ci, ServerUser, ref rsltMsg, !MyServer.RequireAuthentication))
                {
                    rslt = ReplyType.OK;
                }
            }

            PacketReply rep = CreateStandardReply(msg, rslt, rsltMsg);
            msg.ReplyPacket = rep;
        }
示例#48
0
 protected override bool ShouldUpdateFrame(INetworkConnection connection)
 {
     return(base.ShouldUpdateFrame(connection) && ShouldSendTransformInHierarchy(connection));
 }
示例#49
0
        private void OnCharacterListingRequest(INetworkConnection con, Packet msg)
        {
            // character was created successfully.  send a listing of all new characters
            PacketCharacterListing pcl = (PacketCharacterListing)con.CreatePacket((int)PacketType.CharacterListing, 0, false, false);
            List<ICharacterInfo> allToons = CharacterUtil.Instance.GetCharacterListing(this.ServerUser.ID);
            if (allToons.Count == 0)
            {
                if(ServerUser.CurrentCharacter != null)
                {
                    pcl.Characters.Add(ServerUser.CurrentCharacter.CharacterInfo);
                }
                else
                {
                    pcl.Characters = new List<ICharacterInfo>();
                }
            }
            else
            {
                foreach (ICharacterInfo inf in allToons)
                {
                    pcl.Characters.Add(inf);
                }
            }

            msg.ReplyPacket = pcl;
        }
 public SpatialCoordinateSystemParticipant(INetworkConnection connection, GameObject debugVisualPrefab, float debugVisualScale)
 {
     this.debugVisualPrefab = debugVisualPrefab;
     this.debugVisualScale  = debugVisualScale;
     NetworkConnection      = connection;
 }
示例#51
0
        /// <summary>
        /// If it's a UDP null packet, assume it's a keep-alive 
        /// </summary>
        private void OnNATInfo(INetworkConnection con, Packet msg)
        {
            //Log1.Logger("Server.Network").Debug("Got NAT poke from " + ((InboundConnection)con).ServerUser.AccountName);
            // update nat info
            IPEndPoint tcpep = null;
            try
            {
                tcpep = MyTCPSocket.RemoteEndPoint as IPEndPoint;
                if (tcpep == null)
                {
                    return;
                }
            }
            catch
            {
                return;
            }

            UDPSendTarget = new IPEndPoint(tcpep.Address, ((PacketNATInfo)msg).ListenOnPort);
        }
示例#52
0
 private void OnConnection(INetworkConnection connection)
 {
     clients.Add(new Client(connection)); // add new clients to the outstanding clients list. once negotiated, they will be moved to a room.
 }
示例#53
0
        /// <summary>
        /// Adds a socket connection to be tracked by the server
        /// </summary>
        public static bool TrackUserSocket(INetworkConnection client, ref string msg)
        {
            msg = "";
            if (client == null || client.RemoteEndPoint == null)
            {
                return false;
            }

            if (Clients.ContainsKey(client.RemoteEndPoint as IPEndPoint))
            {
                Clients[client.RemoteEndPoint as IPEndPoint].KillConnection("New connection being made from elsewhere...");
                RemoveConnection(client.RemoteEndPoint as IPEndPoint);
            }

            InboundConnection inb = client as InboundConnection;
            if (inb != null && Clients.Count + 1 > inb.MyServer.MaxInboundConnections)
            {
                msg = "Server is full.";
                return false;
            }

            Clients.Add(client.UID, client);
            Clients.Associate(client.RemoteEndPoint as IPEndPoint, client.UID);
            PerfMon.IncrementCustomCounter("Live Connections", 1);
            return true;
        }
示例#54
0
 public void OnServerAuthenticated(INetworkConnection conn)
 {
     conn.RegisterHandler <CreatePlayerMessage>(OnCreatePlayer);
 }
        protected void OnGameNotification(INetworkConnection con, Packet p)
        {
            PacketMatchNotification note = p as PacketMatchNotification;

            if (CurrentGame != null)
            {
                if (CurrentGame.GameID != note.TheGameID)
                {
                    return;
                }
            }

            switch (note.Kind)
            {
                case MatchNotificationType.PlayerRemoved:
                    OnPlayerRemovedFromGame(note);
                    break;
                case MatchNotificationType.PlayerAdded:
                    OnPlayerAddedToGame(note);
                    break;
                case MatchNotificationType.MatchCreated:
                    OnGameCreated(note);
                    break;
                case MatchNotificationType.ObserverAdded:
                    OnObserverAdded(note);
                    break;
                case MatchNotificationType.ObserverRemoved:
                    OnObserverRemoved(note);
                    break;
                case MatchNotificationType.MatchStarted:
                    OnGameStarted(note);
                    break;
                case MatchNotificationType.MatchEnded :
                    OnGameEnded(note);
                    break;
                default:
                    Log.LogMsg("Unhandled packet match notification [" + note.Kind.ToString() + "]");
                    break;
            }
        }
示例#56
0
 public void HandleSyncCommand(INetworkConnection connection, string command, BinaryReader reader, int remainingDataSize)
 {
     reader.ReadSingle(); // float time
     StateSynchronizationSceneManager.Instance.ReceiveMessage(connection, reader);
 }
 private void FireOnBeforeLoginRequest(INetworkConnection con, PacketLoginRequest login)
 {
     if (BeforeLoginRequestInvoker != null)
     {
         BeforeLoginRequestInvoker(con, login);
     }
 }
示例#58
0
 // called after successful authentication
 void OnClientAuthenticated(INetworkConnection conn)
 {
     logger.Log("NetworkSceneManager.OnClientAuthenticated");
     RegisterClientMessages(conn);
 }
示例#59
0
        public override void Read(INetworkConnection connection, BinaryReader message)
        {
#if STATESYNC_TEXTMESHPRO
            EnsureTextComponent();

            TextMeshProBroadcasterChangeType changeType = (TextMeshProBroadcasterChangeType)message.ReadByte();

            if (HasFlag(changeType, TextMeshProBroadcasterChangeType.Text))
            {
                TextMeshObserver.SetText(message.ReadString());
            }

            if (HasFlag(changeType, TextMeshProBroadcasterChangeType.FontAndPlacement))
            {
                AssetId fontId = message.ReadAssetId();
                TextMeshObserver.font = TextMeshProService.Instance.GetFont(fontId);

                bool[] values = Unpack(message.ReadByte());
                TextMeshObserver.autoSizeTextContainer = values[0];
                TextMeshObserver.enableAutoSizing      = values[1];
                TextMeshObserver.enableCulling         = values[2];
                TextMeshObserver.enabled               = values[3];
                TextMeshObserver.enableKerning         = values[4];
                TextMeshObserver.enableWordWrapping    = values[5];
                TextMeshObserver.extraPadding          = values[6];
                TextMeshObserver.ignoreRectMaskCulling = values[7];

                values = Unpack(message.ReadByte());
                TextMeshObserver.ignoreVisibility    = values[0];
                TextMeshObserver.isOrthographic      = values[1];
                TextMeshObserver.isOverlay           = values[2];
                TextMeshObserver.isRightToLeftText   = values[3];
                TextMeshObserver.isVolumetricText    = values[4];
                TextMeshObserver.maskable            = values[5];
                TextMeshObserver.overrideColorTags   = values[6];
                TextMeshObserver.parseCtrlCharacters = values[7];

                values = Unpack(message.ReadByte());
                TextMeshObserver.richText               = values[0];
                TextMeshObserver.tintAllSprites         = values[1];
                TextMeshObserver.useMaxVisibleDescender = values[2];

                TextMeshObserver.alignment                = (TextAlignmentOptions)message.ReadInt32();
                TextMeshObserver.alpha                    = message.ReadSingle();
                TextMeshObserver.color                    = message.ReadColor();
                TextMeshObserver.characterSpacing         = message.ReadSingle();
                TextMeshObserver.characterWidthAdjustment = message.ReadSingle();
                TextMeshObserver.faceColor                = message.ReadColor32();
                TextMeshObserver.firstVisibleCharacter    = message.ReadInt32();
                TextMeshObserver.fontSize                 = message.ReadSingle();
                TextMeshObserver.fontSizeMax              = message.ReadSingle();
                TextMeshObserver.fontSizeMin              = message.ReadSingle();
                TextMeshObserver.fontStyle                = (FontStyles)message.ReadInt32();
                TextMeshObserver.fontWeight               = (FontWeight)message.ReadInt32();
                TextMeshObserver.horizontalMapping        = (TextureMappingOptions)message.ReadByte();
                TextMeshObserver.lineSpacing              = message.ReadSingle();
                TextMeshObserver.lineSpacingAdjustment    = message.ReadSingle();
                TextMeshObserver.mappingUvLineOffset      = message.ReadSingle();
                TextMeshObserver.margin                   = message.ReadVector4();
                TextMeshObserver.maxVisibleCharacters     = message.ReadInt32();
                TextMeshObserver.maxVisibleLines          = message.ReadInt32();
                TextMeshObserver.maxVisibleWords          = message.ReadInt32();
                TextMeshObserver.outlineColor             = message.ReadColor32();
                TextMeshObserver.outlineWidth             = message.ReadSingle();
                TextMeshObserver.overflowMode             = (TextOverflowModes)message.ReadByte();
                TextMeshObserver.pageToDisplay            = message.ReadInt32();
                TextMeshObserver.paragraphSpacing         = message.ReadSingle();
                TextMeshObserver.renderMode               = (TextRenderFlags)message.ReadByte();
                TextMeshObserver.verticalMapping          = (TextureMappingOptions)message.ReadByte();
                TextMeshObserver.wordWrappingRatios       = message.ReadSingle();
                TextMeshObserver.wordSpacing              = message.ReadSingle();

                needsUpdate = true;
            }
#endif
        }
示例#60
0
 public Client(INetworkConnection connection)
 {
     this.connection = connection;
 }