當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。