本文整理汇总了C#中KBEngine.MemoryStream类的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream类的具体用法?C# MemoryStream怎么用?C# MemoryStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryStream类属于KBEngine命名空间,在下文中一共展示了MemoryStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handleMessage
public void handleMessage(MemoryStream msgstream)
{
if(argtypes.Length <= 0)
handler.Invoke(KBEngineApp.app, new object[]{msgstream});
else
handler.Invoke(KBEngineApp.app, createFromStream(msgstream));
}
示例2: checkStream
public void checkStream(int v)
{
if(v > stream.fillfree())
{
streamList.Add(stream);
stream = new MemoryStream();
}
messageLength += v;
}
示例3: checkStream
public void checkStream(int v)
{
if(v > stream.space())
{
streamList.Add(stream);
stream = new MemoryStream();
++ _curMsgStreamIndex;
}
messageLength += v;
}
示例4: send
public bool send(MemoryStream stream)
{
int dataLength = (int)stream.length();
if (dataLength <= 0)
return true;
if (0 == Interlocked.Add(ref _sending, 0))
{
if (_wpos == _spos)
{
_wpos = 0;
_spos = 0;
}
}
int t_spos = Interlocked.Add(ref _spos, 0);
int space = 0;
int tt_wpos = _wpos % _buffer.Length;
int tt_spos = t_spos % _buffer.Length;
if(tt_wpos >= tt_spos)
space = _buffer.Length - tt_wpos + tt_spos - 1;
else
space = tt_spos - tt_wpos - 1;
if (dataLength > space)
{
Dbg.ERROR_MSG("PacketSender::send(): no space, Please adjust 'SEND_BUFFER_MAX'! data(" + dataLength
+ ") > space(" + space + "), wpos=" + _wpos + ", spos=" + t_spos);
return false;
}
int expect_total = tt_wpos + dataLength;
if(expect_total <= _buffer.Length)
{
Array.Copy(stream.data(), stream.rpos, _buffer, tt_wpos, dataLength);
}
else
{
int remain = _buffer.Length - tt_wpos;
Array.Copy(stream.data(), stream.rpos, _buffer, tt_wpos, remain);
Array.Copy(stream.data(), stream.rpos + remain, _buffer, 0, expect_total - _buffer.Length);
}
Interlocked.Add(ref _wpos, dataLength);
if (Interlocked.CompareExchange(ref _sending, 1, 0) == 0)
{
_startSend();
}
return true;
}
示例5: send
public void send(NetworkInterface networkInterface)
{
fini(true);
for(int i=0; i<streamList.Count; i++)
{
stream = streamList[i];
networkInterface.send(stream.getbuffer());
}
streamList.Clear();
stream = new MemoryStream();
}
示例6: writeMsgLength
public void writeMsgLength()
{
if(msgtype.msglen != -1)
return;
MemoryStream stream = this.stream;
if(_curMsgStreamIndex > 0)
{
stream = streamList[streamList.Count - _curMsgStreamIndex];
}
stream.data()[2] = (Byte)(messageLength & 0xff);
stream.data()[3] = (Byte)(messageLength >> 8 & 0xff);
}
示例7: createFromStream
public object[] createFromStream(MemoryStream msgstream)
{
if(argtypes.Length <= 0)
return new object[]{msgstream};
object[] result = new object[argtypes.Length];
for(int i=0; i<argtypes.Length; i++)
{
result[i] = argtypes[i].Invoke(msgstream, new object[0]);
}
return result;
}
示例8: fini
public void fini(bool issend)
{
if(numMessage > 0)
{
writeMsgLength();
streamList.Add(stream);
stream = new MemoryStream();
}
if(issend)
{
numMessage = 0;
msgtype = null;
}
_curMsgStreamIndex = 0;
}
示例9: send
public void send(NetworkInterface networkInterface)
{
fini(true);
if(networkInterface.valid())
{
for(int i=0; i<streamList.Count; i++)
{
stream = streamList[i];
networkInterface.send(stream.getbuffer());
}
}
else
{
Dbg.ERROR_MSG("Bundle::send: networkInterface invalid!");
}
streamList.Clear();
stream = new MemoryStream();
}
示例10: Client_onUpdateBasePosXZ
public void Client_onUpdateBasePosXZ(MemoryStream stream)
{
_entityServerPos.x = stream.readFloat();
_entityServerPos.z = stream.readFloat();
}
示例11: Client_onStreamDataRecv
public void Client_onStreamDataRecv(MemoryStream stream)
{
}
示例12: Client_onSetEntityPosAndDir
/*
服务端强制设置了玩家的坐标
例如:在服务端使用avatar.position=(0,0,0), 或者玩家位置与速度异常时会强制拉回到一个位置
*/
public void Client_onSetEntityPosAndDir(MemoryStream stream)
{
Int32 eid = stream.readInt32();
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
Dbg.ERROR_MSG("KBEngine::Client_onSetEntityPosAndDir: entity(" + eid + ") not found!");
return;
}
entity.position.x = stream.readFloat();
entity.position.y = stream.readFloat();
entity.position.z = stream.readFloat();
entity.direction.x = stream.readFloat();
entity.direction.y = stream.readFloat();
entity.direction.z = stream.readFloat();
Vector3 position = (Vector3)entity.getDefinedPropterty("position");
Vector3 direction = (Vector3)entity.getDefinedPropterty("direction");
Vector3 old_position = new Vector3(position.x, position.y, position.z);
Vector3 old_direction = new Vector3(direction.x, direction.y, direction.z);
position.x = entity.position.x;
position.y = entity.position.y;
position.z = entity.position.z;
direction.x = entity.direction.x;
direction.y = entity.direction.y;
direction.z = entity.direction.z;
entity.setDefinedPropterty("position", position);
entity.setDefinedPropterty("direction", direction);
_entityLastLocalPos = entity.position;
_entityLastLocalDir = entity.direction;
entity.set_direction(old_direction);
entity.set_position(old_position);
}
示例13: Client_onScriptVersionNotMatch
/*
脚本版本不匹配
*/
public void Client_onScriptVersionNotMatch(MemoryStream stream)
{
serverScriptVersion = stream.readString();
Dbg.ERROR_MSG("Client_onScriptVersionNotMatch: verInfo=" + clientScriptVersion + "(server: " + serverScriptVersion + ")");
Event.fireAll("onScriptVersionNotMatch", new object[]{clientScriptVersion, serverScriptVersion});
if(_persistentInofs != null)
_persistentInofs.onScriptVersionNotMatch(clientScriptVersion, serverScriptVersion);
}
示例14: Client_onEntityLeaveWorldOptimized
/*
服务端使用优化的方式通知一个实体离开了世界(如果实体是当前玩家则玩家离开了space, 如果是其他实体则是其他实体离开了玩家的AOI)
*/
public void Client_onEntityLeaveWorldOptimized(MemoryStream stream)
{
Int32 eid = getAoiEntityIDFromStream(stream);
KBEngineApp.app.Client_onEntityLeaveWorld(eid);
}
示例15: Client_onUpdateData_xyz_yr
public void Client_onUpdateData_xyz_yr(MemoryStream stream)
{
Int32 eid = getAoiEntityIDFromStream(stream);
Vector2 xz = stream.readPackXZ();
float y = stream.readPackY();
SByte yaw = stream.readInt8();
SByte r = stream.readInt8();
_updateVolatileData(eid, xz[0], y, xz[1], yaw, KBEDATATYPE_BASE.KBE_FLT_MAX, r, 0);
}