/// <summary> /// Removes message with given id on channel with given id /// </summary> public async Task <bool> RemoveMessageAsync(string channelId, string messageId) { try { IChannelMessageAck response = await NakamaSessionManager.Instance.Socket.RemoveChatMessageAsync(channelId, messageId); Debug.Log("Message removed by username " + response.Username + ", on channel " + response.ChannelId + ", on date " + response.CreateTime); return(true); } catch (Exception e) { Debug.LogError("Message removing error: " + e); return(false); } }
/// <summary> /// Sends new message to channel with given id /// </summary> public async void SendNewMessage(string channelId, string message) { try { //Pack message content to json string jsonMessage = (new Dictionary <string, string> { { "message", message } }).ToJson(); IChannelMessageAck response = await NakamaSessionManager.Instance.Socket.WriteChatMessageAsync(channelId, jsonMessage); Debug.Log("Message created by username " + response.Username + ", on channel " + response.ChannelId + ", on date " + response.CreateTime); } catch (Exception e) { Debug.LogError("Message sending error: " + e); } }
/// <summary> /// Updates message with given id on channel with given id /// </summary> public async Task <bool> EditMessageAsync(string channelId, string messageId, string message) { try { //Pack message content to json string jsonMessage = (new Dictionary <string, string> { { "message", message } }).ToJson(); IChannelMessageAck response = await NakamaSessionManager.Instance.Socket.UpdateChatMessageAsync(channelId, messageId, jsonMessage); Debug.Log("Message edited by username " + response.Username + ", on channel " + response.ChannelId + ", on date " + response.CreateTime); return(true); } catch (Exception e) { Debug.LogError("Message edit error: " + e); return(false); } }
public async void TopicSendMessage(string channelId, string messageJson) { IChannelMessageAck messageAck = await _socket.WriteChatMessageAsync(channelId, messageJson); Debug.LogFormat($"message sent to {channelId} , messageAck : {messageAck}"); }