Beispiel #1
0
    void sendAllBuffers()
    {
        byte error = 0;

        // to each
        for (int i = 0; i < playerOwned.Count; ++i)
        {
            PlayerOwnedInfo poi = playerOwned[i];
            if (poi.connectionId == ServerPSId)
            {
                continue;
            }
            SerializedBuffer buffer_reliable   = poi.sendBuffers[0];
            SerializedBuffer buffer_unreliable = poi.sendBuffers[1];
            if (buffer_reliable.getCommandCount() > 0)
            {
                buffer_reliable.seal();
                NetworkTransport.Send(socketId, poi.connectionId, reliableCHN, buffer_reliable.getBuffer(), buffer_reliable.getOffset(), out error);
                buffer_reliable.reset();
            }
            if (buffer_unreliable.getCommandCount() > 0)
            {
                buffer_unreliable.seal();
                NetworkTransport.Send(socketId, poi.connectionId, unreliableCHN, buffer_unreliable.getBuffer(), buffer_unreliable.getOffset(), out error);
                buffer_unreliable.reset();
            }
        }
    }
Beispiel #2
0
    void Awake()
    {
        self = this;
        Application.runInBackground = true;
        NetworkTransport.Init();
        GlobalConfig gConfig = new GlobalConfig();

        gConfig.MaxPacketSize = 500;
        NetworkTransport.Init(gConfig);

        ConnectionConfig config = new ConnectionConfig();

        reliableCHN   = config.AddChannel(QosType.AllCostDelivery);
        unreliableCHN = config.AddChannel(QosType.StateUpdate);

        HostTopology topology = new HostTopology(config, 10); // max connections

        socketId = NetworkTransport.AddHost(topology, clientPort);
        Debug.Log("Socket Open. SocketId is: " + socketId);
        recvBuffer             = new byte[1024];
        synchronizedComponents = new Dictionary <int, ReplicatedProperties>();
        sendBuffer             = new SerializedBuffer[2];
        sendBuffer[0]          = new SerializedBuffer();
        sendBuffer[1]          = new SerializedBuffer();
    }
Beispiel #3
0
 public PlayerOwnedInfo(int _connId)
 {
     connectionId = _connId;
     if (connectionId >= 0)
     {
         sendBuffers    = new SerializedBuffer[2];
         sendBuffers[0] = new SerializedBuffer();
         sendBuffers[1] = new SerializedBuffer();
     }
     else
     {
         sendBuffers = null;
     }
     gameObjectsOwned = new List <GameObjectSpawnInfo>();
 }