Example #1
0
    public void Send(NetCommand command)
    {
        var baseReq = command.CreateRequest();

        if (Constants.ISCLIENT)
        {
            return;
        }

        Debug.Log(command + " 发送的数据数据:" + Dump.ToDump(baseReq, new DumpSettings()
        {
            MaxDepth = 10
        }));
        System.IO.MemoryStream stream = new System.IO.MemoryStream();
        ProtoBuf.Serializer.Serialize <ProtoBuf.IExtensible>(stream, baseReq);
        System.Byte[] bs      = stream.ToArray();
        HTTPRequest   request = new HTTPRequest(new System.Uri(Constants.API_URL), HTTPMethods.Post, OnServerResponse);

        request.Tag     = command;
        request.RawData = bs;
        //  绑定
        command.CurrRequest = request;
        //  发送数据
        request.Send();
    }