示例#1
0
    public static void Sum(int a, int b)
    {
        PooledNetworkWriter pooledNetworkWriter = NetworkWriterPool.GetWriter();

        pooledNetworkWriter.Write(a);
        pooledNetworkWriter.Write(b);

        Player.SendData(DataCommand.TEST_SumOnServer, pooledNetworkWriter.ToArray());
        pooledNetworkWriter.Dispose();
    }
示例#2
0
    public static void SenderFuction(int a, bool b)
    {
        PooledNetworkWriter pooledNetworkWriter = NetworkWriterPool.GetWriter();

        pooledNetworkWriter.Write(a);
        pooledNetworkWriter.Write(b);

        Player.SendData(DataCommand.TEST1, pooledNetworkWriter.ToArray());
        pooledNetworkWriter.Dispose();
    }
示例#3
0
    public void SumOnServer(byte[] serverReceivedData)
    {
        PooledNetworkReader pooledNetworkReader = NetworkReaderPool.GetReader(serverReceivedData);
        int a = pooledNetworkReader.Read <int>();
        int b = pooledNetworkReader.Read <int>();

        pooledNetworkReader.Dispose();
        PooledNetworkWriter pooledNetworkWriter = NetworkWriterPool.GetWriter();
        int result = a + b;

        pooledNetworkWriter.Write(result);
        pooledNetworkWriter.ToArray();
        byte[] dataToSendClient = pooledNetworkWriter.ToArray();
        Debug.LogWarning("Server " + result);
        RpcReceive(DataCommand.TEST_SumOnServer, dataToSendClient);
        pooledNetworkWriter.Dispose();
    }