当前位置: 首页>>代码示例>>C#>>正文


C# PirateMessage.GetBytes方法代码示例

本文整理汇总了C#中PirateSpades.Network.PirateMessage.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# PirateMessage.GetBytes方法的具体用法?C# PirateMessage.GetBytes怎么用?C# PirateMessage.GetBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PirateSpades.Network.PirateMessage的用法示例。


在下文中一共展示了PirateMessage.GetBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateBroadcastInfo

 /// <summary>
 /// Update broadcast information.
 /// </summary>
 private void UpdateBroadcastInfo()
 {
     var msg = new PirateMessage(PirateMessageHead.Bcst, PirateMessage.ConstructHostInfo(this));
     this.Broadcaster.Message = msg.GetBytes();
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:8,代码来源:PirateHost.cs

示例2: SendMessage

 /// <summary>
 /// Send message to a client.
 /// </summary>
 /// <param name="pclient">Client to send to.</param>
 /// <param name="msg">Message to send.</param>
 public void SendMessage(PirateClient pclient, PirateMessage msg)
 {
     Contract.Requires(pclient != null && msg != null);
     try {
         byte[] buffer = msg.GetBytes();
         pclient.Socket.BeginSend(
             buffer, 0, buffer.Length, SocketFlags.None, MessageSent, new PirateMessageObj(pclient, msg));
     } catch(SocketException ex) {
         if(!IgnoreSocketErrors.Contains(ex.SocketErrorCode)) Console.WriteLine("SocketException:" + ex);
         this.SocketDisconnect(pclient);
     }catch(Exception ex){
         Console.WriteLine(ex);
     }
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:19,代码来源:PirateHost.cs

示例3: SendMessage

 /// <summary>
 /// Send socket message asynchronously.
 /// </summary>
 /// <param name="msg">The message to send.</param>
 public void SendMessage(PirateMessage msg)
 {
     Contract.Requires(msg != null);
     var buffer = msg.GetBytes();
     Socket.BeginSend(buffer, 0, buffer.Length, SocketFlags.None, MessageSent, msg);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:10,代码来源:PirateClient.cs

示例4: KnockKnock

 /// <summary>
 /// Check if host is available.
 /// </summary>
 /// <param name="socket">The socket to communicate through.</param>
 /// <returns>True if host is available, false if not.</returns>
 public static bool KnockKnock(Socket socket)
 {
     Contract.Requires(socket != null);
     var knock = new PirateMessage(PirateMessageHead.Knck, "");
     socket.Send(knock.GetBytes());
     var buffer = new byte[PirateMessage.BufferSize];
     var read = socket.Receive(buffer);
     return read > 4 && PirateMessage.GetMessages(buffer, read).Any(msg => msg.Head == PirateMessageHead.Knck);
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:14,代码来源:PirateClientCommands.cs

示例5: PirateMessageObj

 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="msg">The message to get the byte buffer from.</param>
 public PirateMessageObj(PirateClient client, PirateMessage msg)
 {
     Contract.Requires(client != null && msg != null);
     this.Client = client;
     this.Buffer = msg.GetBytes();
 }
开发者ID:webrokeit,项目名称:PirateSpades,代码行数:11,代码来源:PirateMessageObj.cs


注:本文中的PirateSpades.Network.PirateMessage.GetBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。