当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.setTop方法代码示例

本文整理汇总了C#中ByteBuffer.setTop方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.setTop方法的具体用法?C# ByteBuffer.setTop怎么用?C# ByteBuffer.setTop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.setTop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: transToTargetData

    private static bool transToTargetData(TransCenterSockets tcs)
    {
        Log.Info (getSocketStr(tcs.socketClient) + tcs.socketClient.Available);
        ByteBuffer data = new ByteBuffer (tcs.socketClient.Available);
        data.setTop (tcs.socketClient.Available);
        tcs.socketClient.Receive (data.getArray (), SocketFlags.None);
        tcs.transPortServer.isServer = true;

        try {
            tcs.transPortServer.dataBuffer = data.Clone() as ByteBuffer;
            tcs.transPortServer.receive (data, true);

        } catch (Exception e) {
            Log.Error (e.Message);
        }
        data.position = 0;
        tcs.socketServer.Send (data.getArray ());
        return true;
    }
开发者ID:hebbaixue99,项目名称:XJDemoServer,代码行数:19,代码来源:TransCenter.cs

示例2: transToClientData

    private static bool transToClientData(TransCenterSockets tcs)
    {
        Log.Info ( getSocketStr(tcs.socketServer)+ tcs.socketServer.Available);
        ByteBuffer data = new ByteBuffer (tcs.socketServer.Available);
        data.setTop (tcs.socketServer.Available);
        tcs.socketServer.Receive (data.getArray (), SocketFlags.None);

            tcs.transPortClient.isServer = false;
            try {

                CallBack cb = delegate {
                    data.position = 0;
                    tcs.socketClient.Send (data.getArray ());
                };
                tcs.transPortClient.erlConnect.transCallBack = null;
                tcs.transPortClient.dataBuffer = data.Clone () as ByteBuffer;
                tcs.transPortClient.receive (data, false);

                if (data.length () == 10) {
                    data.position = 0;
                    tcs.transPortServer.isServer = true;
                    tcs.transPortServer.dataBuffer = data.Clone () as ByteBuffer;
                    tcs.transPortServer.receive (data, true);
                }

            } catch (Exception e) {
                Log.Error (e.Message);
            } finally {

                //Log.Info ("+++++" + ports + "+++++++++++");
                //if (ports!=5) {

                //}
            }

        return false;
    }
开发者ID:hebbaixue99,项目名称:XJDemoServer,代码行数:37,代码来源:TransCenter.cs

示例3: receive

 public override void receive()
 {
     if (!base.socket.Connected) {
         if (base.ConnectInvalidBack != null) {
             base.ConnectInvalidBack ();
         }
     }
     //else if (!GameManager.Instance.disconnetNoRecieve)
     {
         base.ActiveTime = TimeKit.getMillisTime ();
         if (base.socket.Available > 0) {
             if (!this._isConnectReady) {
                 byte[] buffer = new byte[1];
                 base.socket.Receive (buffer, SocketFlags.None);
                 byte[] buffer2 = new byte[1];
                 base.socket.Receive (buffer2, SocketFlags.None);
                 byte[] buffer3 = new byte[4];
                 base.socket.Receive (buffer3, SocketFlags.None);
                 Array.Reverse (buffer3);
                 int seed = BitConverter.ToInt32 (buffer3, 0);
                 byte[] buffer4 = new byte[4];
                 base.socket.Receive (buffer4, SocketFlags.None);
                 Array.Reverse (buffer4);
                 int num2 = BitConverter.ToInt32 (buffer4, 0);
                 this._sendChallengeCode = this.getPK (seed);
                 this._receiveChallengeCode = this.getPK (num2);
                 this._isConnectReady = true;
                 if (base.CallBack != null) {
                     base.CallBack ();
                 }
             } else {
                 if (this.length <= 0) {
                     if (base.socket.Available < 2) {
                         return;
                     }
                     byte[] buffer5 = new byte[2];
                     base.socket.Receive (buffer5, SocketFlags.None);
                     this.length = ByteKit.readUnsignedShort (buffer5, 0);
                 }
                 if ((this.length > 0) && (base.socket.Available >= this.length)) {
                     ByteBuffer socketbuffer = new ByteBuffer (this.length);
                     socketbuffer.setTop (this.length);
                     base.socket.Receive (socketbuffer.getArray (), SocketFlags.None);
                     this.parseMessage (socketbuffer);
                 }
             }
         }
     }
 }
开发者ID:hebbaixue99,项目名称:XJDemoServer,代码行数:49,代码来源:ErlConnect.cs

示例4: TransReceive

    public void TransReceive(ByteBuffer data , bool isServer  )
    {
        base.ActiveTime = TimeKit.getMillisTime ();
        if (this.dataBuffer.top > 0) {
            if (!this._isConnectReady) {
                byte[] buffer = new byte[1];
                //base.socket.Receive (buffer, SocketFlags.None);
                Log.Debug (this.dataBuffer.position);
                this.dataBuffer.readBytes(buffer,0,1);

                byte[] buffer2 = new byte[1];
                Log.Debug (this.dataBuffer.position);
                this.dataBuffer.readBytes (buffer2,0, 1);
                //base.socket.Receive (buffer2, SocketFlags.None);
                byte[] buffer3 = new byte[4];
                Log.Debug (this.dataBuffer.position);
                //data.bytesRead ();
                this.dataBuffer.readBytes (buffer3,0, 4);
                //base.socket.Receive (buffer3, SocketFlags.None);
                Array.Reverse (buffer3);
                int seed = BitConverter.ToInt32 (buffer3, 0);
                byte[] buffer4 = new byte[4];
                Log.Debug (this.dataBuffer.position);
                this.dataBuffer.readBytes (buffer4, 0, 4);
                //base.socket.Receive (buffer4, SocketFlags.None);
                Array.Reverse (buffer4);
                int num2 = BitConverter.ToInt32 (buffer4, 0);
                this._sendChallengeCode = this.getPK (seed);
                this._receiveChallengeCode = this.getPK (num2);
                this._isConnectReady = true;
                /*if (base.CallBack != null) {
                    base.CallBack ();
                }*/
                if (this.dataBuffer.bytesAvailable > 0) {
                    this.TransReceive  (null, this.isServer);
                } else {
                    int len = this.dataBuffer.position;
                    byte[] tmp = new byte[len];
                    this.dataBuffer.position = 0;
                    this.dataBuffer.readBytes (tmp, 0, len);
                    if (!this.isServer) {
                        this.socket.Send (tmp);
                    }
                    this.dataBuffer.clear ();

                }
                if (this.transCallBack != null) {
                    this.transCallBack.Invoke ();
                }

            } else {
                if (this.length <= 0) {
                    if ((this.dataBuffer.bytesAvailable) < 2) {
                        if (this.transCallBack != null) {
                            this.transCallBack.Invoke ();
                        }
                        return;
                    }
                    byte[] buffer5 = new byte[2];
                    this.dataBuffer.readBytes(buffer5, 0,2);
                    this.length = ByteKit.readUnsignedShort (buffer5, 0);
                }
                if ((this.length > 0) && ((this.dataBuffer.bytesAvailable) >= this.length)) {
                    ByteBuffer socketbuffer = new ByteBuffer (this.length);
                    socketbuffer.setTop (this.length);
                    this.myPos = this.dataBuffer.position;
                    this.myLen = this.length ;
                    this.dataBuffer.readBytes (socketbuffer.getArray (), 0, this.length);
                    //base.socket.Receive (socketbuffer.getArray (), SocketFlags.None);
                    this.TransParseMessage (socketbuffer, isServer,data);
                }
            }
        }
    }
开发者ID:hebbaixue99,项目名称:XJDemoServer,代码行数:74,代码来源:ErlConnect.cs

示例5: receive

 public virtual void receive()
 {
     if ((this.Active && this.socket.Connected) && (this.socket.Available > 0))
     {
         if (this.len <= 0)
         {
             this.len = this.readLength();
         }
         if (this.len <= this.socket.Available)
         {
             ByteBuffer data = new ByteBuffer(this.len);
             data.setTop(this.len);
             this.socket.Receive(data.getArray(), SocketFlags.None);
             this.len = 0;
             this.receive(data);
         }
     }
 }
开发者ID:hebbaixue99,项目名称:XJDemoServer,代码行数:18,代码来源:Connect.cs


注:本文中的ByteBuffer.setTop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。