Exemplo n.º 1
0
    /*
     * private void ReceiveAllTime()
     * {
     *      Debug.Log("ReceiveAllTime");
     * if (Connected && connected)
     * {
     *  try
     *  {
     *      int dataLength = 0;
     *      dataLength = socket.Available;
     *
     *      if (dataLength != 0)
     *      {
     *          var dataBuffer = new byte[dataLength];
     *          socket.Receive(dataBuffer);
     *          bgISocket.receiveData(dataBuffer);
     *      }
     *  }
     *  catch (Exception e)
     *  {
     *      Debug.LogWarning(e.ToString());
     *      Debug.LogWarning("ReceiveAllTime Disconnect");
     *      if (connected) disconnect();
     *  }
     * }
     * }
     */
    public void onUpdate(float delta)
    {
        //if (socketReceiveThread == null) ReceiveAllTime();
        if (state > BGSocketState.idle)
        {
            switch (state)
            {
            case BGSocketState.connected:
                connected = true;
                bgISocket.socketConnected();
                break;

            case BGSocketState.disconnected:
                Debug.Log("#@@$$BGSocketState.disconnected");
                bgISocket.scoketDiconnected();

                break;

            case BGSocketState.received:
                break;
            }
            state = BGSocketState.idle;
            if (connected && connected != Connected)
            {
                Debug.LogWarning("Where socket disconned not send by function???");
                if (bgISocket != null)
                {
                    bgISocket.scoketDiconnected();
                }
            }
        }
    }
Exemplo n.º 2
0
    public void onUpdate(float delta)
    {
        ReceiveAllTime();
        switch (state)
        {
        case BGSocketState.disconnected:

            if (connected)
            {
                FrameDelayCall.remove(checkcall);

                if (socket != null)
                {
                    socket.Disconnect(true);
                }
                //socket=null;
                //socketReceiveHandler=null;
                //socketReceiveThread=null;
                bgISocket.scoketDiconnected();
            }
            connected = false;


            break;
        }
        state = BGSocketState.idle;
    }
Exemplo n.º 3
0
 public void run()
 {
     while (true)
     {
         try
         {
             int dataLength = 0;
             dataLength = socket.Available;
             var dataBuffer = new byte[dataLength];
             if (socket != null)
             {
                 socket.Receive(dataBuffer);
             }
             if (dataLength != 0)
             {
                 bgISocket.receiveData(dataBuffer);
             }
         }
         catch (Exception e)
         {
             Debug.LogWarning(e.ToString());
             bgISocket.scoketDiconnected();
         }
         Thread.Sleep(10);
     }
 }