本文整理汇总了C#中KBEngine.MemoryStream.data方法的典型用法代码示例。如果您正苦于以下问题:C# MemoryStream.data方法的具体用法?C# MemoryStream.data怎么用?C# MemoryStream.data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KBEngine.MemoryStream
的用法示例。
在下文中一共展示了MemoryStream.data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: copy
public void copy(MemoryStream ms)
{
this.wpos = ms.wpos;
this.rpos = ms.rpos;
Array.Copy(ms.data(), this.data(), ms.data().Length);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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);
}
示例6: onUpdatePropertys_
public void onUpdatePropertys_(Int32 eid, MemoryStream stream)
{
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
MemoryStream entityMessage = null;
if(_bufferedCreateEntityMessage.TryGetValue(eid, out entityMessage))
{
Dbg.ERROR_MSG("KBEngine::Client_onUpdatePropertys: entity(" + eid + ") not found!");
return;
}
MemoryStream stream1 = new MemoryStream();
stream1.wpos = stream.wpos;
stream1.rpos = stream.rpos - 4;
Array.Copy(stream.data(), stream1.data(), stream.data().Length);
_bufferedCreateEntityMessage[eid] = stream1;
return;
}
ScriptModule sm = EntityDef.moduledefs[entity.className];
Dictionary<UInt16, Property> pdatas = sm.idpropertys;
while(stream.length() > 0)
{
UInt16 utype = 0;
if(sm.usePropertyDescrAlias)
{
utype = stream.readUint8();
}
else
{
utype = stream.readUint16();
}
Property propertydata = pdatas[utype];
utype = propertydata.properUtype;
System.Reflection.MethodInfo setmethod = propertydata.setmethod;
object val = propertydata.utype.createFromStream(stream);
object oldval = entity.getDefinedProptertyByUType(utype);
// Dbg.DEBUG_MSG("KBEngine::Client_onUpdatePropertys: " + entity.className + "(id=" + eid + " " +
// propertydata.name + "=" + val + "), hasSetMethod=" + setmethod + "!");
entity.setDefinedProptertyByUType(utype, val);
if(setmethod != null)
{
if(propertydata.isBase() || entity.inWorld)
setmethod.Invoke(entity, new object[]{oldval});
}
}
}
示例7: Client_onUpdatePropertys
public void Client_onUpdatePropertys(MemoryStream stream)
{
Int32 eid = stream.readInt32();
Entity entity = null;
if(!entities.TryGetValue(eid, out entity))
{
MemoryStream entityMessage = null;
if(bufferedCreateEntityMessage.TryGetValue(eid, out entityMessage))
{
Dbg.ERROR_MSG("KBEngine::Client_onUpdatePropertys: entity(" + eid + ") not found!");
return;
}
MemoryStream stream1 = new MemoryStream();
stream1.wpos = stream.wpos;
stream1.rpos = stream.rpos - 4;
Array.Copy(stream.data(), stream1.data(), stream.data().Length);
bufferedCreateEntityMessage[eid] = stream1;
return;
}
Dictionary<UInt16, Property> pdatas = EntityDef.moduledefs[entity.classtype].idpropertys;
while(stream.opsize() > 0)
{
UInt16 utype = stream.readUint16();
Property propertydata = pdatas[utype];
System.Reflection.MethodInfo setmethod = propertydata.setmethod;
object val = propertydata.utype.createFromStream(stream);
object oldval = entity.getDefinedProptertyByUType(utype);
Dbg.DEBUG_MSG("KBEngine::Client_onUpdatePropertys: " + entity.classtype + "(id=" + eid + " " + propertydata.name + "=" + val + "), hasSetMethod=" + setmethod + "!");
entity.setDefinedProptertyByUType(utype, val);
if(setmethod != null)
{
setmethod.Invoke(entity, new object[]{oldval});
}
}
}