/// <summary> /// テキストデータ送信 /// </summary> /// <param name="data"></param> /// <returns></returns> public void SendMessage(string data) { if (dataType == DataType.Byte) { SendMessage(Encoding.UTF8.GetBytes(data)); } else { #if UNITY_UWP if (ws != null && task.IsCompleted == true) { task = Task.Run(async() => { using (var writer = new DataWriter(ws.OutputStream)) { writer.WriteString(data); await writer.StoreAsync(); writer.DetachStream(); } }); } #elif UNITY_EDITOR || UNITY_STANDALONE if (ws != null) { ws.Send(data); } #endif } }
void WebSocketSendMessage(object message) { if (!_webSocket.IsAlive) { return; } _webSocket.Send(message.ToString()); // Debug.Log("SendMessage\n"+message.ToString()); }
public async Task <ResponseMessage> SendMessageAsync(RequestMessage message) { int?msgId = message.Type == RequestMessage.MessageType.Auth ? null : new int?(NextId()); string json = message.BuildRequestJson(msgId); sentMessages.Add(message.DetermineMessageId().GetValueOrDefault(), message); ws.Send(json); return(await message.Task); }
public void sendMessage(string channelID, string message) { wsPostMessageData msgData = new wsPostMessageData { id = Time.time.ToString(), //適当に type = "message", channel = channelID, //"D4WNU3BK7", //@haruka "C4WNTPLQM", //random text = message }; #if WINDOWS_UWP #else ws.Send(JsonUtility.ToJson(msgData)); #endif }
public void Send(byte[] buffer) { m_Socket.Send(buffer); }