Пример #1
0
 public OutgoingMasterServerPeer(IRpcProtocol protocol, IPhotonPeer nativePeer, GameApplication application)
     : base(protocol, nativePeer)
 {
     this.application = application;
     log.InfoFormat("connection to master at {0}:{1} established (id={2}), serverId={3}", this.RemoteIP, this.RemotePort, this.ConnectionId, GameApplication.ServerId);
     this.RequestFiber.Enqueue(this.Register);
 }
 public OutgoingMasterServerPeer(IRpcProtocol protocol, IPhotonPeer nativePeer, GameApplication application)
     : base(protocol, nativePeer)
 {
     this.application = application;
     log.InfoFormat("connection to master at {0}:{1} established (id={2}), serverId={3}", this.RemoteIP, this.RemotePort, this.ConnectionId, GameApplication.ServerId);
     this.RequestFiber.Enqueue(this.Register);
 }
Пример #3
0
 public MmoPeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer, GameApplication application)
     : base(rpcProtocol, nativePeer)
 {
     Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
     this.application = application;
     this.SetCurrentOperationHandler(this);
 }
Пример #4
0
        /// <summary>
        ///   Called when [init].
        /// </summary>
        /// <param name = "peer">The peer.</param>
        /// <param name = "data">The data.</param>
        public void OnInit(IPhotonPeer peer, byte[] data, byte channelCount)
        {
            try
            {
                if (log.IsDebugEnabled)
                {
                    Encoding utf8Encoding = Encoding.UTF8;
                    log.DebugFormat("OnInit - {0}", utf8Encoding.GetString(data));
                }

                if (data[0] == '<' && data[21] == '>')
                {
                    byte[] bytes = peer.GetLocalPort() == 943 ? this.silverlightPolicyBytesUtf8 : this.policyBytesUtf8;

                    // in case the policy app ever serves a websocket port...
                    MessageContentType contentType = peer.GetListenerType() == ListenerType.WebSocketListener
                                                         ? MessageContentType.Text
                                                         : MessageContentType.Binary;

                    peer.Send(bytes, MessageReliablity.Reliable, 0, contentType);

                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Policy sent.");
                    }
                }

                peer.DisconnectClient(); // silverlight does not disconnect by itself
            }
            catch (Exception e)
            {
                log.Error(e);
                throw;
            }
        }
Пример #5
0
 public OutgoingMasterServerPeer(IRpcProtocol protocol, IPhotonPeer nativePeer, SubServer subServer)
     : base(protocol, nativePeer)
 {
     _application = subServer;
     Log.InfoFormat("connection to master at {0}:{1} established (id={2})", RemoteIP, RemotePort, ConnectionId);
     RequestFiber.Enqueue(Register);
 }
Пример #6
0
 /// <summary>
 /// Called by the unmanaged socket server when a peer's send buffer reaches it's limit or is freed again.
 /// </summary>
 /// <param name="photonPeer"> The unmanaged peer.</param>
 /// <param name="userData">The user data.</param>
 /// <param name="flowControlEvent">The flow control event.</param>
 void IPhotonApplication.OnFlowControlEvent(IPhotonPeer photonPeer, object userData, FlowControlEvent flowControlEvent)
 {
     try
     {
         IManagedPeer peer = userData as IManagedPeer;
         if (peer == null)
         {
             log.ErrorFormat("OnFlowControlEvent - Peer {0}'s user data is of wrong type or null: {1}; event {2}", new object[] { photonPeer.GetConnectionID(), userData, flowControlEvent });
             photonPeer.DisconnectClient();
         }
         else
         {
             if (log.IsDebugEnabled)
             {
                 log.DebugFormat("OnFlowControlEvent: Peer={0}; event={1}", new object[] { photonPeer.GetConnectionID(), flowControlEvent });
             }
             if (flowControlEvent == FlowControlEvent.FlowControlAllOk)
             {
                 peer.Application_OnSendBufferEmpty();
             }
         }
     }
     catch (Exception exception)
     {
         log.Error(exception);
         throw;
     }
 }
Пример #7
0
 /// <summary>
 /// Called by the unmanaged socket server if a peer disconnects (or is disconnected).
 /// </summary>
 /// <param name="photonPeer">The peer which disconnected.</param>
 /// <param name="userData"> The user data.</param>
 /// <param name="reasonCode">The disconnect reason code.</param>
 /// <param name="reasonDetail">The disconnect reason detail.</param>
 /// <param name="rtt">The round trip time.</param>
 /// <param name="rttVariance">The round trip time variance.</param>
 /// <param name="numFailures"> The amount of failures. </param>
 void IPhotonApplication.OnDisconnect(IPhotonPeer photonPeer, object userData, DisconnectReason reasonCode, string reasonDetail, int rtt, int rttVariance, int numFailures)
 {
     try
     {
         IManagedPeer peer = userData as IManagedPeer;
         if (peer != null)
         {
             if (log.IsDebugEnabled)
             {
                 log.DebugFormat("OnDisconnect - ConnID={0}", new object[] { photonPeer.GetConnectionID() });
             }
             if (peer.Application_OnDisconnect(reasonCode, reasonDetail, rtt, rttVariance, numFailures))
             {
                 this.DecrementPeerCounter();
             }
         }
         else if (log.IsDebugEnabled)
         {
             log.DebugFormat("OnDisconnect - Peer not found: {0}", new object[] { photonPeer.GetConnectionID() });
         }
     }
     catch (Exception exception)
     {
         log.Error(exception);
         throw;
     }
     finally
     {
         photonPeer.SetUserData(null);
     }
 }
Пример #8
0
        //---------------------------------------------------------------------
        public PhotonServerPeerC(IRpcProtocol protocol, IPhotonPeer unmanaged_peer,
                                 EntityMgr entity_mgr, byte remote_node_type, RpcSessionListener listener)
            : base(protocol, unmanaged_peer)
        {
            mEntityMgr      = entity_mgr;
            mRpcSession     = new RpcSession(mEntityMgr, this);
            mListener       = listener;
            mRemoteNodeType = remote_node_type;

            Dictionary <byte, object> map_param = new Dictionary <byte, object>();

            map_param[0] = mEntityMgr.NodeType;
            map_param[1] = 0;// local_node_id
            OperationRequest operation_request = new OperationRequest((byte)_eRpcCmd.SyncPeerInfo, map_param);
            SendResult       r = SendOperationRequest(operation_request, new SendParameters {
                ChannelId = 0
            });

            if (r != SendResult.Ok)
            {
                EbLog.Error("PhotonServerPeerC SyncPeerInfo Result=" + r);
            }

            if (mListener != null)
            {
                mListener.onSessionConnect(mEntityMgr.NodeType, mRemoteNodeType, mRpcSession);
            }
        }
Пример #9
0
        // usually the Photon.SocketServer.Application provides the path but Policy is not inheriting that

        /// <summary>
        ///   OnDisconnect callback.
        /// </summary>
        /// <param name = "peer">
        ///   The peer.
        /// </param>
        /// <param name = "userData">
        ///   The user data.
        /// </param>
        /// <param name = "reasonCode">Disconnect reason code.</param>
        /// <param name = "reasonDetail">Disconnect reason details.</param>
        /// <param name = "rtt">The round trip time.</param>
        /// <param name = "rttVariance">The round trip time variance.</param>
        /// <param name = "numFailures">The number of failures. </param>
        public void OnDisconnect(
            IPhotonPeer peer,
            object userData,
            DisconnectReason reasonCode,
            string reasonDetail,
            int rtt,
            int rttVariance,
            int numFailures)
        {
            if (log.IsInfoEnabled && reasonCode != DisconnectReason.ClientDisconnect && reasonCode != DisconnectReason.ManagedDisconnect)
            {
                log.InfoFormat(
                    "OnDisconnect: PID {0}, {1} ({2}), RTT: {3}, Variance: {4}, Failures:{5}",
                    peer.GetConnectionID(),
                    reasonCode,
                    reasonDetail,
                    rtt,
                    rttVariance,
                    numFailures);
            }
            else if (log.IsDebugEnabled)
            {
                log.DebugFormat(
                    "OnDisconnect: PID {0}, {1} ({2}), RTT: {3}, Variance: {4}, Failures:{5}",
                    peer.GetConnectionID(),
                    reasonCode,
                    reasonDetail,
                    rtt,
                    rttVariance,
                    numFailures);
            }
        }
Пример #10
0
 public REPeer(IRpcProtocol rpcprotocol, IPhotonPeer nativePeer, REServer serverApplication)
     : base(rpcprotocol,nativePeer)
 {
     guid = Guid.NewGuid();
     server = serverApplication;
     server.wandererDictionary.Add(guid, this);
 }
 public OutgoingMasterServerPeer(IRpcProtocol protocol, IPhotonPeer nativePeer, SubServer subServer)
     : base(protocol, nativePeer)
 {
     _application = subServer;
     Log.InfoFormat("connection to master at {0}:{1} established (id={2})", RemoteIP, RemotePort, ConnectionId);
     RequestFiber.Enqueue(Register);
 }
    public StarCollectorPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
        : base(protocol, unmanagedPeer)
    {
        #region Assigned ID
        lock (allocateIDLock)
        {
            playerID = lastAssignedID;
            lastAssignedID++;
        }

        //notify player of their ID
        EventData evt = new EventData()
        {
            Code = (byte)AckEventType.AssignPlayerID,
            Parameters = new Dictionary<byte, object>()
            {
                { (byte)Parameter.PlayerID, this.playerID }
            }
        };
        evt.Parameters[(byte)Parameter.PlayerID] = playerID;
        this.SendEvent(evt, new SendParameters());
        #endregion

        #region Join to world
        lock (StarCollectorGame.Instance)
        {
            StarCollectorGame.Instance.PeerJoined(this);
        }
        #endregion
    }
Пример #13
0
    public StarCollectorPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
        : base(protocol, unmanagedPeer)
    {
        #region Assigned ID
        lock (allocateIDLock)
        {
            playerID = lastAssignedID;
            lastAssignedID++;
        }

        //notify player of their ID
        EventData evt = new EventData()
        {
            Code       = (byte)AckEventType.AssignPlayerID,
            Parameters = new Dictionary <byte, object>()
            {
                { (byte)Parameter.PlayerID, this.playerID }
            }
        };
        evt.Parameters[(byte)Parameter.PlayerID] = playerID;
        this.SendEvent(evt, new SendParameters());
        #endregion

        #region Join to world
        lock (StarCollectorGame.Instance)
        {
            StarCollectorGame.Instance.PeerJoined(this);
        }
        #endregion
    }
Пример #14
0
 /// <summary>
 /// Called by the unmanaged socket server when new data was received.
 /// </summary>
 /// <param name="photonPeer">The peer who sent the operation.</param>
 /// <param name="userData">The user data.</param>
 /// <param name="data">The data for the operation.</param>
 /// <param name="reliability">Message reliable flags for the operation.</param>
 /// <param name="channelId">The channel ID.</param>
 /// <param name="messageContentType">The Message Content Type.</param>
 /// <param name="rtt"> The round trip time.</param>
 /// <param name="rttVariance">The round trip time variance.</param>
 /// <param name="numFailures"> The number of failures.</param>
 void IPhotonApplication.OnReceive(IPhotonPeer photonPeer, object userData, byte[] data, MessageReliablity reliability, byte channelId, MessageContentType messageContentType, int rtt, int rttVariance, int numFailures)
 {
     try
     {
         PhotonCounter.OperationReceiveCount.Increment();
         PhotonCounter.OperationReceivePerSec.Increment();
         if (operationDataLogger.IsDebugEnabled)
         {
             operationDataLogger.DebugFormat("OnReceive - ConnID={0}, data=({1} bytes) {2}", new object[] { photonPeer.GetConnectionID(), data.Length, BitConverter.ToString(data) });
         }
         IManagedPeer peer = userData as IManagedPeer;
         if (peer == null)
         {
             log.ErrorFormat("OnReceive - Peer {0}'s user data is of wrong type or null: {1}", new object[] { photonPeer.GetConnectionID(), userData });
             photonPeer.DisconnectClient();
         }
         else
         {
             SendParameters sendParameters = new SendParameters
             {
                 Unreliable = reliability == MessageReliablity.UnReliable,
                 ChannelId  = channelId
             };
             peer.Application_OnReceive(data, sendParameters, rtt, rttVariance, numFailures);
         }
     }
     catch (Exception exception)
     {
         log.Error(exception);
         throw;
     }
 }
Пример #15
0
 public void Connect()
 {
     lock (this.syncRoot)
     {
         if (this.isENet)
         {
             this.photonPeer = this.application.ApplicationSink.ConnectENet(this.remoteEndPoint.Address.ToString(), (ushort)this.remoteEndPoint.Port, this.numChannels, this, this.mtu);
         }
         else if (this.useMux)
         {
             this.photonPeer = this.application.ApplicationSink.ConnectMux(this.remoteEndPoint.Address.ToString(), (ushort)this.remoteEndPoint.Port, this);
         }
         else if (this.isWebSocket)
         {
             if (this.isHixie76)
             {
                 this.photonPeer = this.application.ApplicationSink.ConnectHixie76WebSocket(this.remoteEndPoint.Address.ToString(), (ushort)this.remoteEndPoint.Port, this.appName, this.origin, this);
             }
             else
             {
                 this.photonPeer = this.application.ApplicationSink.ConnectWebSocket(this.remoteEndPoint.Address.ToString(), (ushort)this.remoteEndPoint.Port, this.webSocketVersion.GetValueOrDefault(WebSocketVersion.HyBi13), this.appName, Enum.GetName(typeof(ProtocolType), this.protocol.ProtocolType), this);
             }
         }
         else
         {
             this.photonPeer = this.application.ApplicationSink.Connect(this.remoteEndPoint.Address.ToString(), (ushort)this.remoteEndPoint.Port, this);
         }
     }
 }
Пример #16
0
 protected PeerBase(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
 {
     this.unmanagedPeer   = unmanagedPeer;
     this.connectionState = Photon.SocketServer.PeerConnectionStateMachine.Connected.Instance;
     this.protocol        = protocol;
     this.requestFiber    = new PoolFiber();
     this.requestFiber.Start();
 }
Пример #17
0
 public LatencyPeer(IRpcProtocol protocol, IPhotonPeer nativePeer)
     : base(protocol, nativePeer)
 {
     if (log.IsDebugEnabled)
     {
         log.DebugFormat("Latency monitoring client connected, serverId={0}", GameApplication.ServerId);
     }
 }
Пример #18
0
 public ChatPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(protocol, unmanagedPeer)
 {
     lock (syncRoot)
     {
         BroadcastMessage += this.OnBroadcastMessage;
     }
 }
Пример #19
0
 public ChatPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(protocol, unmanagedPeer)
 {
     lock (syncRoot)
     {
         BroadcastMessage += this.OnBroadcastMessage;
     }
 }
Пример #20
0
        public IncomingSubServerPeer(InitRequest initRequest, MasterApplication application)
            : base(initRequest.Protocol, initRequest.PhotonPeer)
        {
            this.application  = application;
            __unmanagedPeer__ = initRequest.PhotonPeer;

            this.ServerId = null;
        }
Пример #21
0
 public StarCollectorDemoPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(protocol, unmanagedPeer)
 {
     lock (StarCollectorDemoGame.Instance)
     {
         StarCollectorDemoGame.Instance.PeerJoined(this);
     }
 }
Пример #22
0
 public LatencyPeer(IRpcProtocol protocol, IPhotonPeer nativePeer)
     : base(protocol, nativePeer)
 {
     if (log.IsDebugEnabled)
     {
         log.DebugFormat("Latency monitoring client connected, serverId={0}", GameApplication.ServerId);
     }
 }
Пример #23
0
 //---------------------------------------------------------------------
 public PhotonServerPeerS(IRpcProtocol rpc_protocol, IPhotonPeer native_peer,
                          EntityMgr entity_mgr, RpcSessionListener listener)
     : base(rpc_protocol, native_peer)
 {
     mEntityMgr  = entity_mgr;
     mRpcSession = new RpcSession(mEntityMgr, this);
     mListener   = listener;
 }
Пример #24
0
        public STServerPeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer, STGameApp ga)
            : base(rpcProtocol, nativePeer)
        {
            game_app = ga;

            this.fiber = new PoolFiber();
            this.fiber.Start();
        }
Пример #25
0
 public PhotonServerPeer(IRpcProtocol protocol, IPhotonPeer photonPeer, IEnumerable <IServerData> serverData, PhotonServerHandlerList handlerList, PhotonApplication application) : base(protocol, photonPeer)
 {
     foreach (var data in serverData)
     {
         _serverData.Add(data.GetType(), data);
     }
     _handlerList = handlerList;
     Server       = application;
 }
Пример #26
0
        /// <summary>
        /// 类型:方法
        /// 名称:ServerPeer
        /// 作者:taixihuase
        /// 作用:构造 ServerPeer 对象
        /// 编写日期:2015/7/12
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="unmanagedPeer"></param>
        /// <param name="server"></param>
        public ServerPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer, ServerApplication server)
            : base(protocol, unmanagedPeer)
        {
            PeerGuid = Guid.NewGuid();
            Server   = server;

            // 将当前 peer 加入连线列表
            Server.Users.AddConnectedPeer(PeerGuid, this);
        }
Пример #27
0
 public IPhotonPeer[] GetUnmanagedPeers()
 {
     IPhotonPeer[] peerArray = new IPhotonPeer[this.Peers.Count];
     for (int i = 0; i < this.Peers.Count; i++)
     {
         peerArray[i] = this.Peers[i].UnmanagedPeer;
     }
     return(peerArray);
 }
Пример #28
0
        /// <summary>
        /// 类型:方法
        /// 名称:ServerPeer
        /// 作者:taixihuase
        /// 作用:构造 ServerPeer 对象
        /// 编写日期:2015/7/12
        /// </summary>
        /// <param name="protocol"></param>
        /// <param name="unmanagedPeer"></param>
        /// <param name="server"></param>
        public ServerPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer, ServerApplication server)
            : base(protocol, unmanagedPeer)
        {
            PeerGuid = Guid.NewGuid();
            Server = server;

            // 将当前 peer 加入连线列表
            Server.Users.AddConnectedPeer(PeerGuid, this);
        }
        /// <summary>
        /// Creates a new outgoing master server peer used to talk with the master
        /// </summary>
        protected OutgoingMasterServerPeer(InitResponse initResponse, SubServerApplication application)
            : base(initResponse.Protocol, initResponse.PhotonPeer)
        {
            this.application       = application;
            this.__unmanagedPeer__ = initResponse.PhotonPeer;

            this.InitializeEncryption();

            this.IsRegistered = false;
        }
Пример #30
0
 public PhotonAckPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(protocol, unmanagedPeer)
 {
     lock ( lockPlayerID )
     {
         this.PlayerID = lastAssignedPlayerID;
         lastAssignedPlayerID++;
     }
     PhotonAckGame.Instance.PeerConnected(this);
 }
Пример #31
0
        public OutgoingServerToServerPeer(IRpcProtocol protocol, IPhotonPeer peer, IOutgoingServerPeer outgoingServerPeerHandler)
            : base(protocol, peer)
        {
            if (outgoingServerPeerHandler == null)
            {
                throw new NullReferenceException("outgoingServerPeerHandler");
            }

            this.outgoingServerPeerHandler = outgoingServerPeerHandler;
            this.outgoingServerPeerHandler.OnConnect(this);
        }
Пример #32
0
 public MarsPeer(IRpcProtocol rpc, IPhotonPeer peer)
     : base(rpc, peer)
 {
     serverOperator  = new ServerOperator(this);
     roleOperator    = new RoleOperator(this);
     messageOperator = new MessageOperator(this);
     teamOperator    = new TeamOperator(this);
     fightOperator   = new FightOperator(this);
     monsterOperator = new MonsterOperator(this);
     HandshakeHandle();
 }
Пример #33
0
 /// <summary>
 /// Logs the init request.
 /// </summary>
 /// <param name="peer">The peer.</param>
 /// <param name="channelId">The channel id.</param>
 /// <param name="data">The data.</param>
 /// <param name="sendResult">The send result.</param>
 private static void LogInitRequest(IPhotonPeer peer, int channelId, byte[] data, SendResult sendResult)
 {
     if (operationDataLogger.IsDebugEnabled)
     {
         operationDataLogger.DebugFormat("SentInitRequest: ConnID={0}, ChannelId={1}, result={2}, data=({3} bytes) {4}", new object[] { peer.GetConnectionID(), channelId, sendResult, data.Length, BitConverter.ToString(data) });
     }
     else if (log.IsDebugEnabled)
     {
         log.DebugFormat("SentInitRequest: ConnID={0}, ChannelId={1}, result={2} size={3} bytes", new object[] { peer.GetConnectionID(), channelId, sendResult, data.Length });
     }
 }
Пример #34
0
 public PhotonClientPeer(IRpcProtocol protocol, IPhotonPeer photonPeer, IEnumerable <IClientData> clientData, PhotonClientHandlerList handlerList, PhotonApplication application)
     : base(protocol, photonPeer)
 {
     _peerID      = Guid.NewGuid();
     _handlerList = handlerList;
     _server      = application;
     foreach (var data in clientData)
     {
         _clientData.Add(data.GetType(), data);
     }
     _server.ConnectionCollection <PhotonConnectionCollection>().Clients.Add(_peerID, this);
 }
Пример #35
0
        public NetworkPeerBase(PokerApplication application, IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
            : base(protocol, unmanagedPeer)
        {
            this.application = application;

            lock (allPeers)
            {
                allPeers.Add(this);
            }

            RegisterHandler <PlayerAnnounceMessage>(ReceivePlayerAnnounce);
        }
Пример #36
0
 /// <summary>
 ///   OnReceive callback.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "userData">
 ///   The user data.
 /// </param>
 /// <param name = "data">
 ///   The data.
 /// </param>
 /// <param name = "reliability">
 ///   The reliability.
 /// </param>
 /// <param name = "channelId">
 ///   The channel id.
 /// </param>
 /// /// <param name = "rtt">The round trip time.</param>
 /// <param name = "rttVariance">The round trip time variance.</param>
 /// <param name = "numFailures">The number of failures. </param>
 public void OnReceive(
     IPhotonPeer peer,
     object userData,
     byte[] data,
     MessageReliablity reliability,
     byte channelId,
     MessageContentType messageContentType,
     int rtt,
     int rttVariance,
     int numFailures)
 {
 }
        public bool BroadcastEvent(IPhotonPeer[] peerList, byte[] data, MessageReliablity reliability, byte channelId, MessageContentType messageContentType, out SendResults[] results)
        {

            results = new SendResults[peerList.Length];

            for (int i = 0; i < peerList.Length; i++)
            {
                results[i] = peerList[i].Send(data, reliability, channelId, messageContentType);
            }

            return true; 
        }
Пример #38
0
        private void Disconnect()
        {
            IPhotonPeer photonPeer;

            lock (this.syncRoot)
            {
                photonPeer = this.photonPeer;
            }
            if (!this.aborted)
            {
                photonPeer.DisconnectClient();
                this.aborted = true;
            }
        }
Пример #39
0
        public MmoPeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer)
            : base(rpcProtocol, nativePeer)
        {
            // this is the operation handler before entering a world
            this.SetCurrentOperationHandler(this);

            #region PopBloop

            string configFile = Path.Combine(DbSettings.BinaryPath, "PopBloopServer.config");
            if (File.Exists(configFile))
            {
                using (StreamReader reader = new StreamReader(configFile))
                {
                    string line = reader.ReadLine();

                    if (line.Length > 1)
                    {
                        string[] config = line.Split('@');
                        string address = config[1];
                        string username = config[0];
                        if (address.Trim().Length > 1 && address.Contains(":"))
                        {
                            DbSettings.DBServerAddress = address;
                            log.Info("DBServerAddress: " + address);
                        }

                        if (username.Trim().Length > 1 && username.Contains(":"))
                        {
                            string[] credentials = username.Split(':');
                            if (credentials.Length == 2)
                            {
                                DbSettings.DBServerUsername = credentials[0];
                                DbSettings.DBServerPassword = credentials[1];
                                log.Info("DBUserName: "******", DBPassword: "******"No credentials found on PopBloopServer.config");
                            }
                        }
                        else
                        {
                            log.Info("Credentials Invalid: '" + username +"'");
                        }
                    }
                }
            }

            #endregion
        }
Пример #40
0
        public ActorPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
            : base(protocol, unmanagedPeer)
        {
            #region Assigned ID
            lock (allocateIDLock)
            {
                playerID = lastAssignedID;
                lastAssignedID++;
            }
            #endregion

            #region Join to Arena
            lock (ServerArena.Instance)
            {
                ServerArena.Instance.Enter(this);
            }
            #endregion
        }
Пример #41
0
        public LatencyMonitor(
            IRpcProtocol protocol, IPhotonPeer nativePeer, byte operationCode, int maxHistoryLength, int intervalMs, WorkloadController workloadController)
            : base(protocol, nativePeer)
        {
            this.operationCode = operationCode;
            this.intervalMs = intervalMs;
            this.workloadController = workloadController;
            this.latencyHistory = new ValueHistory(maxHistoryLength);
            this.averageLatencyMs = 0;
            this.lastLatencyMs = 0;

            log.InfoFormat("{1} connection for latency monitoring established (id={0}), serverId={2}", this.ConnectionId, this.NetworkProtocol, GameApplication.ServerId);

            if (!Stopwatch.IsHighResolution)
            {
                log.InfoFormat("No hires stopwatch!");
            }
            
            this.pingTimer = this.RequestFiber.ScheduleOnInterval(this.Ping, 0, this.intervalMs);
        }
        public PhotonAckPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
            : base(protocol, unmanagedPeer)
        {
            lock (lockPlayerID)
            {
                this.playerID = lastAssignedPlayerID;
                lastAssignedPlayerID++;
            }
            PhotonAckGame.Instance.PeerConnected(this);

            EventData evn = new EventData((byte)AckEventType.AssignPlayerID)
            {
                Parameters = new Dictionary<byte, object>()
                {
                    { (byte)Parameter.PlayerID, this.playerID }
                }
            };
            Console.WriteLine("PhotonAckPeer PlayerID: " + this.playerID);
            this.SendEvent(evn,new SendParameters());
            Console.WriteLine("PhotonAckPeer SendEvent");
        }
Пример #43
0
 public TestHivePeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer)
     : this(new InitRequest(rpcProtocol, nativePeer))
 {
 }
Пример #44
0
 private void handleOnlineStatus(IPhotonPeer peer, int dbId, bool online, int deviceType)
 {
     lock (PeerInstancesOnline)
     {
         if (online)
         {
             if (!PeerInstancesOnline.ContainsKey(peer))
             {
                 PeerInstancesOnline.Add(peer, dbId);
                 ChangeDbOnlineStatus(dbId, true, deviceType);
             }
         }
         else
         {
             if (PeerInstancesOnline.ContainsKey(peer))
             {
                 RequestDetachLaserPointers();
                 
                 ChangeDbOnlineStatus(PeerInstancesOnline[peer], false, deviceType);
                 PeerInstancesOnline.Remove(peer);                        
             }
         }
     }
 }
Пример #45
0
 public MyPeer(IRpcProtocol rpcProtocol, IPhotonPeer peer)
     : base(rpcProtocol, peer)
 {
 }
Пример #46
0
 public PokerPeer(PokerApplication pokerApplication,IRpcProtocol protocol, IPhotonPeer unmanagedPeer)
     : base(pokerApplication,protocol, unmanagedPeer)
 {
     RegisterHandler<VoiceDataMessage>(ReceiveVoiceData);
 }
Пример #47
0
 public MmoPeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer)
     : base(rpcProtocol, nativePeer)
 {
     // this is the operation handler before entering a world
     this.SetCurrentOperationHandler(this);
 }
 public RedirectedClientPeer(IRpcProtocol protocol, IPhotonPeer unmanagedPeer, MasterApplication application)
     : base(protocol, unmanagedPeer)
 {
     this.application = application;
 }
Пример #49
0
 /// <summary>
 ///   OnFlowControlEvent callback.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "userData">
 ///   The user data.
 /// </param>
 /// <param name = "flowControlEvent">
 ///   The flow control event.
 /// </param>
 public void OnFlowControlEvent(IPhotonPeer peer, object userData, FlowControlEvent flowControlEvent)
 {
 }
Пример #50
0
        /// <summary>
        ///   Called when [init].
        /// </summary>
        /// <param name = "peer">The peer.</param>
        /// <param name = "data">The data.</param>
        public void OnInit(IPhotonPeer peer, byte[] data)
        {
            try
            {
                if (log.IsDebugEnabled)
                {
                    Encoding utf8Encoding = Encoding.UTF8;
                    log.DebugFormat("OnInit - {0}", utf8Encoding.GetString(data));
                }

                if (data[0] == '<' && data[21] == '>')
                {
                    byte[] bytes = peer.GetLocalPort() == 943 ? this.silverlightPolicyBytesUtf8 : this.policyBytesUtf8;
                    peer.Send(bytes, MessageReliablity.Reliable, 0);

                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Policy sent.");
                    }
                }

                peer.DisconnectClient(); // silverlight does not disconnect by itself
            }
            catch (Exception e)
            {
                log.Error(e);
                throw;
            }
        }
Пример #51
0
 /// <summary>
 ///   OnOutboundConnectionFailed callback.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "userData">
 ///   The user data.
 /// </param>
 /// <param name = "errorCode">
 ///   The error code.
 /// </param>
 /// <param name = "errorMessage">
 ///   The error message.
 /// </param>
 public void OnOutboundConnectionFailed(IPhotonPeer peer, object userData, int errorCode, string errorMessage)
 {
 }
Пример #52
0
 /// <summary>
 ///   OnReceive callback.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "userData">
 ///   The user data.
 /// </param>
 /// <param name = "data">
 ///   The data.
 /// </param>
 /// <param name = "reliability">
 ///   The reliability.
 /// </param>
 /// <param name = "channelId">
 ///   The channel id.
 /// </param>
 /// /// <param name = "rtt">The round trip time.</param>
 /// <param name = "rttVariance">The round trip time variance.</param>
 /// <param name = "numFailures">The number of failures. </param>
 public void OnReceive(
     IPhotonPeer peer,
     object userData,
     byte[] data,
     MessageReliablity reliability,
     byte channelId,
     int rtt,
     int rttVariance,
     int numFailures)
 {
 }
Пример #53
0
 // usually the Photon.SocketServer.Application provides the path but Policy is not inheriting that
 /// <summary>
 ///   OnDisconnect callback.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "userData">
 ///   The user data.
 /// </param>
 /// <param name = "reasonCode">Disconnect reason code.</param>
 /// <param name = "reasonDetail">Disconnect reason details.</param>
 /// <param name = "rtt">The round trip time.</param>
 /// <param name = "rttVariance">The round trip time variance.</param>
 /// <param name = "numFailures">The number of failures. </param>
 public void OnDisconnect(
     IPhotonPeer peer,
     object userData,
     DisconnectReason reasonCode,
     string reasonDetail,
     int rtt,
     int rttVariance,
     int numFailures)
 {
     if (log.IsInfoEnabled && reasonCode != DisconnectReason.ClientDisconnect && reasonCode != DisconnectReason.ManagedDisconnect)
     {
         log.InfoFormat(
             "OnDisconnect: PID {0}, {1} ({2}), RTT: {3}, Variance: {4}, Failures:{5}",
             peer.GetConnectionID(),
             reasonCode,
             reasonDetail,
             rtt,
             rttVariance,
             numFailures);
     }
     else if (log.IsDebugEnabled)
     {
         log.DebugFormat(
             "OnDisconnect: PID {0}, {1} ({2}), RTT: {3}, Variance: {4}, Failures:{5}",
             peer.GetConnectionID(),
             reasonCode,
             reasonDetail,
             rtt,
             rttVariance,
             numFailures);
     }
 }
Пример #54
0
 /// <summary>
 ///     创建时通过
 /// </summary>
 /// <param name="protocol"></param>
 /// <param name="peer"></param>
 public ClientPeer(IRpcProtocol protocol, IPhotonPeer peer)
     : base(protocol, peer)
 {
     WriteLog("connected.");
 }
Пример #55
0
 public TestHivePeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer, string userId)
     : this(rpcProtocol, nativePeer)
 {
     this.UserId = userId;
 }
Пример #56
0
 public DiscussionPeer(IRpcProtocol rpcProtocol, IPhotonPeer photonPeer)
     : base(rpcProtocol, photonPeer)
 {
     _photonPer = photonPeer;
 }
Пример #57
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "LitePeer" /> class.
 /// </summary>
 /// <param name = "rpcProtocol">
 ///   The rpc protocol.
 /// </param>
 /// <param name = "nativePeer">
 ///   The native peer.
 /// </param>
 public LitePeer(IRpcProtocol rpcProtocol, IPhotonPeer nativePeer)
     : base(rpcProtocol, nativePeer)
 {
 }
Пример #58
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "LiteLobbyPeer" /> class.
 /// </summary>
 /// <param name = "rpcProtocol">
 ///   The rpc Protocol.
 /// </param>
 /// <param name = "photonPeer">
 ///   The photon peer.
 /// </param>
 public LiteLobbyPeer(IRpcProtocol rpcProtocol, IPhotonPeer photonPeer)
     : base(rpcProtocol, photonPeer)
 {
 }
Пример #59
0
 /// <summary>
 ///   OnOutboundConnectionEstablished callback.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "userData">
 ///   The user data.
 /// </param>
 public void OnOutboundConnectionEstablished(IPhotonPeer peer, object userData)
 {
 }
Пример #60
0
 public ClientPeer(IRpcProtocol protocol,IPhotonPeer unmanagedPeer)
     : base(protocol,unmanagedPeer)
 {
 }