Base class for all network Peers or Sessions in GladNet.
Inheritance: INetPeer, IClassLogger, IDisconnectable
        /// <summary>
        /// Called when Photon internally disconnects the peer.
        /// </summary>
        /// <param name="reasonCode">Reason for disconnecting.</param>
        /// <param name="reasonDetail">Detailed reason string.</param>
        protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
        {
            //Null the peer out otherwise we will leak. Trust me.
            GladNetPeer = null;

            //Disconnects the peer
            disconnectionServiceHandler.Disconnect();

            networkReciever.OnNetworkMessageReceive(new PhotonStatusMessageAdapter(NetStatus.Disconnected), null);
        }
		/// <summary>
		/// Called when Photon internally disconnects the peer.
		/// </summary>
		/// <param name="reasonCode">Reason for disconnecting.</param>
		/// <param name="reasonDetail">Detailed reason string.</param>
		protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
		{
			//Null the peer out otherwise we will leak. Trust me.
			GladNetPeer = null;

			//Disconnects the peer
			disconnectionServiceHandler.Disconnect();

			networkReciever.OnNetworkMessageReceive(new PhotonStatusMessageAdapter(NetStatus.Disconnected), null);
		}
		protected override void OnConnectionEstablished(object responseObject)
		{
			//We connected so we should publish that fact
			IConnectionDetails details = new PhotonServerIConnectionDetailsAdapter(this.RemoteIP, this.RemotePort, this.LocalPort);

			//This is a horrible way to do it but I did not expect this sort of change in Photon 4.
			GladNetPeer = ((GladNetAppBase)GladNetAppBase.Instance).CreateServerPeer(new PhotonServerINetworkMessageSenderClientAdapter(this, ((GladNetAppBase)GladNetAppBase.Instance).Serializer),
				details, (INetworkMessageSubscriptionService)networkReciever, disconnectionServiceHandler, ((GladNetAppBase)GladNetAppBase.Instance).routebackService);

			//If we failed to generate a peer
			if(GladNetPeer == null)
			{
				this.Disconnect();
				return;
			}

			//Add the ID to the AUID map service and setup removal
			((GladNetAppBase)GladNetAppBase.Instance).auidMapService.Add(details.ConnectionID, GladNetPeer);
			disconnectionServiceHandler.DisconnectionEventHandler += () => ((GladNetAppBase)GladNetAppBase.Instance).auidMapService.Remove(details.ConnectionID);

			networkReciever.OnNetworkMessageReceive(new PhotonStatusMessageAdapter(NetStatus.Connected), null);
		}
Exemplo n.º 4
0
        protected override void OnConnectionEstablished(object responseObject)
        {
            //We connected so we should publish that fact
            IConnectionDetails details = new PhotonServerIConnectionDetailsAdapter(this.RemoteIP, this.RemotePort, this.LocalPort);

            //This is a horrible way to do it but I did not expect this sort of change in Photon 4.
            GladNetPeer = ((GladNetAppBase)GladNetAppBase.Instance).CreateServerPeer(new PhotonServerINetworkMessageSenderClientAdapter(this, ((GladNetAppBase)GladNetAppBase.Instance).Serializer),
                                                                                     details, (INetworkMessageSubscriptionService)networkReciever, disconnectionServiceHandler, ((GladNetAppBase)GladNetAppBase.Instance).routebackService);

            //If we failed to generate a peer
            if (GladNetPeer == null)
            {
                this.Disconnect();
                return;
            }

            //Add the ID to the AUID map service and setup removal
            ((GladNetAppBase)GladNetAppBase.Instance).auidMapService.Add(details.ConnectionID, GladNetPeer);
            disconnectionServiceHandler.DisconnectionEventHandler += () => ((GladNetAppBase)GladNetAppBase.Instance).auidMapService.Remove(details.ConnectionID);

            networkReciever.OnNetworkMessageReceive(new PhotonStatusMessageAdapter(NetStatus.Connected), null);
        }