/// <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)); }
/// <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("")); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }