Exemplo n.º 1
0
 private void OnDestroy()
 {
     if (peer != null && peer.PeerState == PeerStateValue.Connected)
     {
         peer.Disconnect();
     }
 }
Exemplo n.º 2
0
 private void OnDisable()
 {
     if (null != clientpeer)
     {
         clientpeer.Disconnect();
     }
 }
Exemplo n.º 3
0
 private void OnDestroy()
 {
     if (peer != null && peer.PeerState == PeerStateValue.Disconnected) //判断连接状态
     {
         peer.Disconnect();                                             //断开连接
     }
 }
Exemplo n.º 4
0
 private void OnDestroy()
 {
     if (peer != null && peer.PeerState == PeerStateValue.Connected)     // 当脚本销毁时,如果peer不为空且连接状态处于连接时,断开连接
     {
         peer.Disconnect();
     }
 }
Exemplo n.º 5
0
        private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
        {
            var listner = new PhotonListener(false);
            var peer    = new PhotonPeer(listner, protocol);

            if (!peer.Connect(serverAddress, appId))
            {
                return(false);
            }

            var counter = 100;

            while (--counter > 0)
            {
                peer.Service();
                if (listner.WaitForConnection(0))
                {
                    var res = peer.PeerState == PeerStateValue.Connected;
                    peer.Disconnect();
                    return(res);
                }
                Thread.Sleep(50);
            }
            return(false);
        }
Exemplo n.º 6
0
 public override void ShutDown()
 {
     if (peer != null && peer.PeerState == PeerStateValue.Connected)
     {
         peer.Disconnect();
     }
 }
Exemplo n.º 7
0
 public void OnDestroy()
 {
     if (selfPeer != null)
     {
         selfPeer.Disconnect();
     }
 }
Exemplo n.º 8
0
        public void Close()
        {
            PhotonClient.Disconnect();

            StopService();
            StopExecute();
        }
Exemplo n.º 9
0
 private void Disconnect()
 {
     if (PhotonPeer != null)
     {
         PhotonPeer.Disconnect();
     }
 }
Exemplo n.º 10
0
        private void ExecuteCommand(string cmd)
        {
            if (!connected)
            {
                return;
            }

            switch (cmd.Trim().ToLower())
            {
            case "push":
            {
                Dictionary <byte, object> parameters = new Dictionary <byte, object> {
                    { (byte)ParameterCode.Type, (byte)ClientSettings.Default.PushType },
                    { (byte)ParameterCode.Body, ClientSettings.Default.Body },
                    { (byte)ParameterCode.Title, ClientSettings.Default.Title }
                };
                mPeer.OpCustom((byte)SelectCharacterOperationCode.SendPushToPlayers, parameters, true);
                Console.WriteLine("push sended");
            }
            break;

            case "exit":
            {
                mPeer.Disconnect();
                mLoopStarted = false;
            }
            break;
            }
        }
Exemplo n.º 11
0
 /// <summary>
 /// 切断
 /// </summary>
 public void Disconnect()
 {
     if (Peer != null)
     {
         Peer.Disconnect();
         Peer = null;
     }
 }
Exemplo n.º 12
0
 void OnDestroy()
 {
     //判断是否已经断开连接
     if (peer.PeerState == PeerStateValue.Disconnected)
     {
         peer.Disconnect();
     }
 }
Exemplo n.º 13
0
 //当游戏关闭的时候(停止运行)调用OnDestroy
 private void OnDestroy()
 {
     //如果peer不等于空并且状态为正在连接
     if (peer != null && peer.PeerState == PeerStateValue.Connected)
     {
         peer.Disconnect();//断开连接
     }
 }
Exemplo n.º 14
0
 protected override void OnDestroy()
 {
     //base.OnDestroy();
     if (peer != null && peer.PeerState == PeerStateValue.Connected)
     {
         peer.Disconnect(); //程序退出,关闭连接
     }
 }
    void OnDestroy()
    {
        Peer.Disconnect();
//        if (peer!=null&&peer.PeerState==PeerStateValue.Connected)
//        {
//            peer.Disconnect();
//        }
    }
Exemplo n.º 16
0
 public void Disconnect()
 {
     if (peer != null)
     {
         peer.Disconnect();
         peer = null;
     }
 }
Exemplo n.º 17
0
 void OnDestroy()
 {
     // explicitly disconnect if the client game object is destroyed
     if (Connected)
     {
         Connection.Disconnect();
     }
 }
Exemplo n.º 18
0
    public void Disconnect()
    {
        if (_peer != null)
        {
            _peer.Disconnect();
        }

        _state = new Disconnected();
    }
Exemplo n.º 19
0
 public void SocketDisconnect()
 {
     GameDataSend();
     user          = null;
     userattribute = null;
     socket.Shutdown(SocketShutdown.Both);
     myPeer.Disconnect();
     socket.Close();
 }
Exemplo n.º 20
0
 private void OnDestroy()
 {
     try
     {
         peer.Disconnect();
     }
     catch (Exception e)
     {
         Debug.Log(e.Message);
     }
 }
Exemplo n.º 21
0
 public void Disconnect()
 {
     try
     {
         peer.Disconnect();
     }
     catch (Exception ex)
     {
         DebugReturn(DebugLevel.ERROR, ex.Message);
         DebugReturn(DebugLevel.ERROR, ex.StackTrace);
     }
 }
Exemplo n.º 22
0
 public void Disconnect()
 {
     try
     {
         if (this.peer != null)
         {
             peer.Disconnect();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 23
0
        private static bool CheckConnection(string serverAddress, string appId, ConnectionProtocol protocol)
        {
            var listner = new PhotonListener(false);
            var peer = new PhotonPeer(listner, protocol);

            if (!peer.Connect(serverAddress, appId))
            {
                return false;
            }

            var counter = 100;
            while (--counter > 0)
            {
                peer.Service();
                if (listner.WaitForConnection(0))
                {
                    var res = peer.PeerState == PeerStateValue.Connected;
                    peer.Disconnect();
                    return res;
                }
                Thread.Sleep(50);
            }
            return false;
        }
Exemplo n.º 24
0
 void OnDestroy()
 {
     m_Peer.Disconnect();
 }
Exemplo n.º 25
0
 void OnApplicationQuit()
 {
     peer.Disconnect();
 }
Exemplo n.º 26
0
 public void OnApplicationQuit()
 {
     _photonPeer.Disconnect();
 }
Exemplo n.º 27
0
 private void OnDestroy()
 {
     peer.Disconnect();
 }
Exemplo n.º 28
0
 public void Disconnect()
 {
     _peer.Disconnect();
 }
Exemplo n.º 29
0
 private void Disconnect()
 {
     m_PhotonPeer.Disconnect();
     Connected = false;
 }
Exemplo n.º 30
0
 public void Disconnect()
 {
     _peer.SendOutgoingCommands();
     _peer.Disconnect();
 }
Exemplo n.º 31
0
        // Thread method that implements a finite state machine to connect to photon server and send outgoing messages periodically
        private void photonUpdate()
        {
            // Keep looping until conditions are met to terminate and exit fsm
            while (currState != State.TERMINATED)
            {
                // Print out if any state transitions have been made
                if (prevState != currState)
                {
                    Log.debug("PhotonLiteCommManager: " + getStateString(prevState) + " -> " + getStateString(currState));
                }

                // Make copy of current state
                prevState = currState;

                // Take action based on current state and whether we are in normal
                // operation mode or trying to terminate
                switch (currState)
                {
                case State.DISCONNECTED:     // No connections exist and no pending connections
                {
                    if (terminateRequested)
                    {
                        // Indicate to the fsm to stop and exit
                        currState = State.TERMINATED;
                    }
                    else
                    {
                        // Try (re)connecting to the photon server
                        currState = State.CONNECTING;
                        Log.debug("PhotonLiteCommManager: Connecting to Photon server at " + ipAddress);
                        peer.Connect(ipAddress, roomName);
                    }
                    break;
                }

                case State.CONNECTING:     // Current connecting to server
                {
                    if (terminateRequested)
                    {
                        // Cancel request to connect to server
                        currState = State.DISCONNECTING;
                        peer.Disconnect();
                    }
                    else
                    {
                        // Do nothing, just wait for response
                    }
                    break;
                }

                case State.CONNECTED:     // Connected to the server, no request to join room sent yet
                {
                    if (terminateRequested)
                    {
                        // Disconnect from the server
                        currState = State.DISCONNECTING;
                        peer.Disconnect();
                    }
                    else
                    {
                        // Connected to Photon server, now join our game
                        Log.debug("PhotonLiteCommManager: Joining room \"" + roomName + "\"");
                        currState = State.JOINING;
                        Dictionary <byte, object> opParams = new Dictionary <byte, object>();
                        opParams[LiteOpKey.GameId] = roomName;
                        peer.OpCustom((byte)LiteOpCode.Join, opParams, true);
                    }
                    break;
                }

                case State.JOINING:     // Currently joining a room
                {
                    if (terminateRequested)
                    {
                        // Cancel request to join room
                        currState = State.LEAVING;
                        Dictionary <byte, object> opParams = new Dictionary <byte, object>();
                        opParams[LiteOpKey.GameId] = roomName;
                        peer.OpCustom((byte)LiteOpCode.Leave, opParams, true);
                    }
                    else
                    {
                        // Do nothing, just wait for response
                    }
                    break;
                }

                case State.JOINED:     // Connected to both server and game
                {
                    if (terminateRequested)
                    {
                        // Leave the room first
                        currState = State.LEAVING;
                        Dictionary <byte, object> opParams = new Dictionary <byte, object>();
                        opParams[LiteOpKey.GameId] = roomName;
                        peer.OpCustom((byte)LiteOpCode.Leave, opParams, true);
                    }
                    else
                    {
                        // We are within a game room.  Send any messages waiting
                        // on our outgoing queue
                        sendOutgoing();
                    }
                    break;
                }

                default:
                    break;
                }

                // Print out if any state transitions have been made
                if (prevState != currState)
                {
                    Log.debug("PhotonLiteCommManager: " + getStateString(prevState) + " -> " + getStateString(currState));
                }

                // Make copy of current state
                prevState = currState;

                // Communicate with Photon server
                peer.Service();

                // Wait a while before talking with server again
                System.Threading.Thread.Sleep(updateSleepTime_ms);
            }
        }