コード例 #1
0
        /// <summary>
        /// Conversation-less message.
        /// </summary>
        /// <param name="message">Message to modify</param>
        /// <param name="nickname">When sending, this should be Receiver's nickname. On the receiving side, this should be Sender's nickname.</param>
        /// <param name="content">Message content</param>
        /// <returns></returns>
        public static Message DirectText(this Message message, string nickname, string content)
        {
            var nicknameBytes = Encoding.Unicode.GetBytes(nickname);
            var contentBytes  = Encoding.Unicode.GetBytes(content);

            var bytes = nicknameBytes.Concat(new byte[] { 0x0, 0x0 }).Concat(contentBytes).ToArray();

            return(message.Type(Message.MessageType.DirectText).Content(bytes));
        }
コード例 #2
0
 /// <summary>
 /// Client sends this message to avoid timeout.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <returns></returns>
 public static Message KeepAlive(this Message message)
 {
     return(message.Type(Message.MessageType.KeepAlive).Content(""));
 }
コード例 #3
0
 /// <summary>
 /// Client sends this message to server on disconnect.
 /// Server sends this message on client disconnect caused by server.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <param name="reason">Optional reason for disconnect</param>
 /// <returns></returns>
 public static Message Bye(this Message message, string reason)
 {
     return(message.Type(Message.MessageType.Bye).Content(reason));
 }
コード例 #4
0
 /// <summary>
 /// Client sends this message with its nickname to server on connection.
 /// Server sends this message on client connection as response.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <param name="nickname">Client's nickname</param>
 /// <returns></returns>
 public static Message Hello(this Message message, string nickname)
 {
     return(message.Type(Message.MessageType.Hello).Content(nickname));
 }
コード例 #5
0
 /// <summary>
 /// Server sends this message to clients in conversation to signify that the conversation has been closed.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <param name="reason">Optional reason</param>
 /// <returns></returns>
 public static Message CloseConversation(this Message message, string reason)
 {
     return(message.Type(Message.MessageType.CloseConversation).Content(reason));
 }
コード例 #6
0
        /// <summary>
        /// Client sends this message to calling client, carrying its response to call request.
        /// </summary>
        /// <param name="message">Message to modify</param>
        /// <param name="callerId">Calling client's ID</param>
        /// <param name="responseType">Response to call</param>
        /// <returns></returns>
        public static Message CallResponse(this Message message, short callerId, Message.CallResponseType responseType)
        {
            var content = new[] { (byte)responseType };

            return(message.Type(Message.MessageType.CallResponse).Content(content).Receiver(callerId));
        }
コード例 #7
0
 /// <summary>
 /// Server sends this message to called client. Client should respond with CallResponse.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <param name="nickname">Nickname of calling user</param>
 /// <returns></returns>
 public static Message CallRequest(this Message message, string nickname)
 {
     return(message.Type(Message.MessageType.CallRequest).Content(nickname));
 }
コード例 #8
0
 /// <summary>
 /// Audio message. Content should be already encoded.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <param name="samples">Encoded audio samples</param>
 /// <returns></returns>
 public static Message Audio(this Message message, byte[] samples)
 {
     return(message.Type(Message.MessageType.Audio).Content(samples));
 }
コード例 #9
0
 /// <summary>
 /// Standard text message.
 /// </summary>
 /// <param name="message">Message to modify</param>
 /// <param name="content">Message text content</param>
 /// <returns></returns>
 public static Message Text(this Message message, string content)
 {
     return(message.Type(Message.MessageType.Text).Content(content));
 }