本文整理汇总了C#中ByteBuffer.Close方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.Close方法的具体用法?C# ByteBuffer.Close怎么用?C# ByteBuffer.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPbcMessage
/// <summary>
/// pbc消息
/// </summary>
void OnPbcMessage(ClientSession session, ByteBuffer buffer) {
tutorial.Person request = ProtoUtil.GetMessage<tutorial.Person>(buffer);
Console.WriteLine("OnPbcMessage id=>>" + request.id + " name:>>>" + request.name);
buffer.Close(); buffer = null;
byte[] data = ProtoUtil.SetMessage<tutorial.Person>(request);
ByteBuffer newBuffer = new ByteBuffer();
newBuffer.WriteByte((byte)ProtocalType.PBC);
newBuffer.WriteBytes(data); //添加数据
SocketUtil.SendMessage(session, Protocal.Login, newBuffer);
}
示例2: OnPbLuaMessage
/// <summary>
/// pblua消息
/// </summary>
/// <param name="session"></param>
/// <param name="buffer"></param>
void OnPbLuaMessage(ClientSession session, ByteBuffer buffer) {
LoginRequest request = ProtoUtil.GetMessage<LoginRequest>(buffer);
Console.WriteLine("OnPbLuaMessage id=>>" + request.id + " name:>>>" + request.name + " email:>>" + request.email);
buffer.Close(); buffer = null;
LoginResponse response = new LoginResponse();
response.id = 100; //排队人数
byte[] data = ProtoUtil.SetMessage<LoginResponse>(response);
ByteBuffer newBuffer = new ByteBuffer();
newBuffer.WriteByte((byte)ProtocalType.PB_LUA);
newBuffer.WriteBytes(data); //添加数据
SocketUtil.SendMessage(session, Protocal.Login, newBuffer);
}
示例3: SendMessage
/// <summary>
/// 发送消息
/// </summary>
public void SendMessage(ByteBuffer buffer)
{
SessionSend(buffer.ToBytes());
buffer.Close();
}
示例4: OnSprotoMessage
/// <summary>
/// sproto消息
/// </summary>
void OnSprotoMessage(ClientSession session, ByteBuffer buffer) {
byte[] data = buffer.ReadBytes();
//-------------------------------------------------------------
SprotoPack spack = new SprotoPack();
byte[] pack_data = spack.pack(data); // pack
byte[] unpack_data = spack.unpack(pack_data); // unpack
AddressBook addr = new AddressBook(unpack_data); // decode
Console.WriteLine("OnSprotoMessage id=>>" + addr.person.Count);
buffer.Close(); buffer = null;
//-------------------------------------------------------------
ByteBuffer newBuffer = new ByteBuffer();
newBuffer.WriteByte((byte)ProtocalType.SPROTO);
newBuffer.WriteBytes(data); //添加数据
SocketUtil.SendMessage(session, Protocal.Login, newBuffer);
}
示例5: ConnectToServer
public void ConnectToServer(string host,int port,ByteBuffer login_msg)
{
SocketClient.ConnectToServer(host, port, login_msg.ToBytes());
login_msg.Close();
}