本文整理汇总了C#中KBEngine.MemoryStream类的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream类的具体用法?C# MemoryStream怎么用?C# MemoryStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemoryStream类属于KBEngine命名空间,在下文中一共展示了MemoryStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:hellopcworld,项目名称:kbengine,代码行数:7,代码来源:Message.cs
示例2: checkStream
public void checkStream(int v)
{
if(v > stream.fillfree())
{
streamList.Add(stream);
stream = new MemoryStream();
}
messageLength += v;
}
开发者ID:life02,项目名称:kbengine-cocos2dx,代码行数:10,代码来源:Bundle.cs
示例3: checkStream
public void checkStream(int v)
{
if(v > stream.space())
{
streamList.Add(stream);
stream = new MemoryStream();
++ _curMsgStreamIndex;
}
messageLength += v;
}
开发者ID:jiangzhuo,项目名称:kbengine_dotnet,代码行数:11,代码来源:Bundle.cs
示例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;
}
开发者ID:kbengine,项目名称:kbengine_unity3d_plugins,代码行数:54,代码来源:PacketSender.cs
示例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();
}
开发者ID:life02,项目名称:kbengine-cocos2dx,代码行数:13,代码来源:Bundle.cs
示例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);
}
开发者ID:hcy12321,项目名称:KBEngine-LearnNote,代码行数:13,代码来源:Bundle.cs
示例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;
}
开发者ID:hellopcworld,项目名称:kbengine,代码行数:14,代码来源:Message.cs
示例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;
}
开发者ID:jiangzhuo,项目名称:kbengine_dotnet,代码行数:18,代码来源:Bundle.cs
示例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();
}
开发者ID:kjdjpan,项目名称:kbengine_unity3d_plugins,代码行数:20,代码来源:Bundle.cs
示例10: Client_onUpdateBasePosXZ
public void Client_onUpdateBasePosXZ(MemoryStream stream)
{
_entityServerPos.x = stream.readFloat();
_entityServerPos.z = stream.readFloat();
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:5,代码来源:KBEngine.cs
示例11: Client_onStreamDataRecv
public void Client_onStreamDataRecv(MemoryStream stream)
{
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:3,代码来源:KBEngine.cs
示例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);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:45,代码来源:KBEngine.cs
示例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);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:13,代码来源:KBEngine.cs
示例14: Client_onEntityLeaveWorldOptimized
/*
服务端使用优化的方式通知一个实体离开了世界(如果实体是当前玩家则玩家离开了space, 如果是其他实体则是其他实体离开了玩家的AOI)
*/
public void Client_onEntityLeaveWorldOptimized(MemoryStream stream)
{
Int32 eid = getAoiEntityIDFromStream(stream);
KBEngineApp.app.Client_onEntityLeaveWorld(eid);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:8,代码来源:KBEngine.cs
示例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);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:12,代码来源:KBEngine.cs
示例16: Client_onLoginFailed
/*
登录loginapp失败了
*/
public void Client_onLoginFailed(MemoryStream stream)
{
UInt16 failedcode = stream.readUint16();
_serverdatas = stream.readBlob();
Dbg.ERROR_MSG("KBEngine::Client_onLoginFailed: failedcode(" + failedcode + "), datas(" + _serverdatas.Length + ")!");
Event.fireAll("onLoginFailed", new object[]{failedcode});
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:10,代码来源:KBEngine.cs
示例17: Client_onImportServerErrorsDescr
/*
服务端错误描述导入了
*/
public void Client_onImportServerErrorsDescr(MemoryStream stream)
{
byte[] datas = new byte[stream.wpos - stream.rpos];
Array.Copy(stream.data(), stream.rpos, datas, 0, stream.wpos - stream.rpos);
onImportServerErrorsDescr (stream);
if(_persistentInofs != null)
_persistentInofs.onImportServerErrorsDescr(datas);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:13,代码来源:KBEngine.cs
示例18: Client_onImportClientMessages
/*
从服务端返回的二进制流导入客户端消息协议
*/
public void Client_onImportClientMessages(MemoryStream stream)
{
byte[] datas = new byte[stream.wpos - stream.rpos];
Array.Copy (stream.data (), stream.rpos, datas, 0, stream.wpos - stream.rpos);
onImportClientMessages (stream);
if(_persistentInofs != null)
_persistentInofs.onImportClientMessages(currserver, datas);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:13,代码来源:KBEngine.cs
示例19: Client_onImportClientEntityDef
public void Client_onImportClientEntityDef(MemoryStream stream)
{
byte[] datas = new byte[stream.wpos - stream.rpos];
Array.Copy (stream.data (), stream.rpos, datas, 0, stream.wpos - stream.rpos);
onImportClientEntityDef (stream);
if(_persistentInofs != null)
_persistentInofs.onImportClientEntityDef(datas);
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:10,代码来源:KBEngine.cs
示例20: Client_onHelloCB
/*
握手之后服务端的回调
*/
public void Client_onHelloCB(MemoryStream stream)
{
serverVersion = stream.readString();
serverScriptVersion = stream.readString();
serverProtocolMD5 = stream.readString();
serverEntitydefMD5 = stream.readString();
Int32 ctype = stream.readInt32();
Dbg.DEBUG_MSG("KBEngine::Client_onHelloCB: verInfo(" + serverVersion
+ "), scriptVersion("+ serverScriptVersion + "), srvProtocolMD5("+ serverProtocolMD5
+ "), srvEntitydefMD5("+ serverEntitydefMD5 + "), + ctype(" + ctype + ")!");
onServerDigest();
if(currserver == "baseapp")
{
onLogin_baseapp();
}
else
{
onLogin_loginapp();
}
}
开发者ID:buckyu,项目名称:kbengine_unity3d_plugins,代码行数:26,代码来源:KBEngine.cs
注:本文中的KBEngine.MemoryStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论