Ejemplo n.º 1
0
 /// <summary>
 /// Called by the unmanaged socket server when a peer intializes the connection.
 /// This method determines the used rpc protocol and then calls <see cref="M:Photon.SocketServer.ApplicationBase.CreatePeer(Photon.SocketServer.InitRequest)">CreatePeer</see>.
 /// </summary>
 /// <param name="nativePeer">The photon peer.</param>
 /// <param name="data"> The data.</param>
 /// <param name="channelCount">The number of channels that will be used by this peer. </param>
 void IPhotonApplication.OnInit(IPhotonPeer nativePeer, byte[] data, byte channelCount)
 {
     try
     {
         InitRequest request;
         PhotonCounter.InitPerSec.Increment();
         if (operationDataLogger.IsDebugEnabled)
         {
             operationDataLogger.DebugFormat("OnInit - ConnID={0}, data=({1} bytes) {2}", new object[] { nativePeer.GetConnectionID(), data.Length, BitConverter.ToString(data) });
         }
         if (log.IsDebugEnabled)
         {
             log.DebugFormat("OnInit - ConnID={0}, IP {1} on port {2}, type = {3}", new object[] { nativePeer.GetConnectionID(), nativePeer.GetRemoteIP(), nativePeer.GetLocalPort(), nativePeer.GetListenerType() });
         }
         if (nativePeer.GetListenerType() == ListenerType.HTTPListener)
         {
             string str = "";
             if (data.Length > 7)
             {
                 str = Encoding.ASCII.GetString(data, 7, data.Length - 7);
                 log.DebugFormat("OnInit - {0}", new object[] { str });
             }
             log.DebugFormat("OnInit - HttpPeer cnnected. " + str, new object[0]);
             if (str.Contains("json"))
             {
                 request = new InitRequest("LiteLobby", new Version(0, 3, 6), JsonProtocol.Instance);
             }
             else
             {
                 request = new InitRequest("LiteLobby", new Version(0, 3, 6), GpBinaryByteProtocolV16.HeaderV2Instance);
             }
         }
         else if (nativePeer.GetListenerType() == ListenerType.WebSocketListener)
         {
             if (!Protocol.TryParseWebSocketInitRequest(data, this.ApplicationName, Versions.DefaultWebsocketPeerVersion, out request))
             {
                 log.Warn("OnInit - Failed to parse init request for WebSocket peer: {0}" + data);
                 nativePeer.DisconnectClient();
                 return;
             }
         }
         else if (!Protocol.TryParseInitRequest(data, out request))
         {
             if (log.IsDebugEnabled)
             {
                 if (data.Length == 0)
                 {
                     log.Debug("OnInit - Data must contain at least one byte.");
                 }
                 else
                 {
                     log.DebugFormat("OnInit - Failed to parse init request with protocol {0}", new object[] { data[0] });
                 }
             }
             nativePeer.DisconnectClient();
             return;
         }
         request.PhotonPeer = nativePeer;
         ThreadPool.QueueUserWorkItem(new WaitCallback(this.CreatePeerInternal), request);
     }
     catch (Exception exception)
     {
         log.Error(exception);
         throw;
     }
 }
Ejemplo n.º 2
0
 public Clientpeer(IRpcProtocol _protocol, IPhotonPeer _unmanagedPeer) : base(_protocol, _unmanagedPeer)
 {
     defaultdata             = new Defaultdata();
     defaultdata.defaultid   = this.GetHashCode().ToString();
     defaultdata.defaultname = "connected use|" + _unmanagedPeer.GetRemoteIP() + " ";
 }
Ejemplo n.º 3
0
 public UnityClient(IRpcProtocol protocol, IPhotonPeer unmanagedPeer) : base(protocol, unmanagedPeer)
 {
     Log.Debug("Client ip:" + unmanagedPeer.GetRemoteIP());
     Position = new Vector3Net(0, 0, 0);
 }
Ejemplo n.º 4
0
 public UnityClient(IRpcProtocol protocol, IPhotonPeer unmanagedPeer) : base(protocol, unmanagedPeer)
 {
     log.Debug("Player connection ip:" + unmanagedPeer.GetRemoteIP());
 }
Ejemplo n.º 5
0
 public UnityClient(IRpcProtocol protocol, IPhotonPeer unmanagedPeer) : base(protocol, unmanagedPeer)
 {
     Log.Info("Player connection ip: " + unmanagedPeer.GetRemoteIP());
     charactersHealths = new Dictionary <string, byte>();
     setUpdateStatsTimer();
 }
Ejemplo n.º 6
0
 public UnityClient(IRpcProtocol protocol, IPhotonPeer unmanagedPeer) : base(protocol, unmanagedPeer)
 {
     Log.Debug("Client ip:" + unmanagedPeer.GetRemoteIP());
 }
Ejemplo n.º 7
0
 public UnityClient(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(protocol, unmanagedPeer)
 {
     Log.Debug("Client ip:" + unmanagedPeer.GetRemoteIP());
     Position = new Vector3Net(0, 0, 0);
 }
Ejemplo n.º 8
0
 public Client(IRpcProtocol protocol, IPhotonPeer peer)
     : base(protocol, peer)
 {
     m_log.Debug("New client: " + peer.GetRemoteIP());
 }
Ejemplo n.º 9
0
 public UnityClient(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(protocol, unmanagedPeer)
 {
     log.Debug("Player connection ip:" + unmanagedPeer.GetRemoteIP());
 }