本文整理汇总了C#中ByteBuffer.getArray方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.getArray方法的具体用法?C# ByteBuffer.getArray怎么用?C# ByteBuffer.getArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.getArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CRC32
public static uint CRC32(ByteBuffer data, uint start, uint len)
{
if (start >= data.top)
{
start = (uint) data.top;
}
if (len == 0)
{
len = ((uint) data.top) - start;
}
if ((len + start) > data.top)
{
len = ((uint) data.top) - start;
}
uint maxValue = uint.MaxValue;
for (uint i = start; i < len; i++)
{
maxValue = crcTable[(int) ((IntPtr) ((maxValue ^ data.getArray()[i]) & 0xff))] ^ (maxValue >> 8);
}
return (maxValue ^ uint.MaxValue);
}
示例2: 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;
}
示例3: 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;
}
示例4: toPK
protected byte[] toPK(int[] pks)
{
ByteBuffer buffer = new ByteBuffer ();
buffer.writeInt (pks [0]);
buffer.writeInt (pks [1]);
buffer.writeInt (pks [2]);
buffer.writeInt (pks [3]);
buffer.writeInt (pks [4]);
buffer.writeInt (pks [5]);
buffer.writeInt (pks [6]);
buffer.writeInt (pks [7]);
return buffer.getArray ();
}
示例5: 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);
}
}
}
}
示例6: 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);
}
}
}
}
}
示例7: 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);
}
}
}