예제 #1
0
    void Update()
    {
        int recHostId;
        int recConnectionId;
        int channelId;

        byte[]           recBuffer  = new byte[bs];
        int              bufferSize = bs;
        int              dataSize;
        byte             error;
        NetworkEventType recData = NetworkTransport.Receive(out recHostId, out recConnectionId, out channelId, recBuffer, bufferSize, out dataSize, out error);

        switch (recData)
        {
        case NetworkEventType.Nothing:
            break;

        case NetworkEventType.ConnectEvent:
            Debug.Log("Connected to host");
            break;

        case NetworkEventType.DataEvent:
            bs = dataSize;

            if (channelId == 2)
            {
                mySquirrel.ReceiveResponse(recBuffer);
            }

            break;

        case NetworkEventType.DisconnectEvent:
            Debug.Log("Disconnected from host");
            break;
        }
    }