//public TcpCommunicator(string host, int port, OnMessageEvent onMessage) : this(new TcpClient(host, port), onMessage) public TcpCommunicator(string host, int port, OnMessageEvent onMessage) : this(new TcpClient(), onMessage) { Debug.Log(2); this.host = host; this.port = port; ProcessIncomingNetworkData(); }
/// <summary> /// /// </summary> /// <param name="buffer"></param> /// <param name="offset"></param> /// <param name="length"></param> protected override void OnBytesRead(byte[] buffer, int offset, int length) { for (var i = offset; i < offset + length; i++) { m_messageData.WriteByte(buffer[i]); } do { if (m_messageLength == -1 && m_messageData.Count > 3) { m_messageLength = m_messageData.ReadInt(); } if (m_messageLength != -1 && m_messageId == -1 && m_messageData.Count > 3) { m_messageId = m_messageData.ReadInt(); } if (m_messageLength != -1 && m_messageId != -1 && m_messageData.Count >= m_messageLength) { var message = MessageBuilder.BuildMessage(m_messageId, m_messageData.ReadBytes(m_messageLength)); OnMessageEvent?.Invoke(message); m_messageId = -1; m_messageLength = -1; } }while ((m_messageLength == -1 || m_messageId == -1) && m_messageData.Count > 3); }
public TcpCommunicator(TcpClient tcpClient, OnMessageEvent onMessage) { this.TcpClient = tcpClient ?? throw new ArgumentNullException(nameof(tcpClient)); this.Name = $"[{Socket.RemoteEndPoint}]"; this.mainContext = SynchronizationContext.Current; this.OnMessage = onMessage; }
public void Log(string msg) { _Messages.Insert(0, new Message() { Timestamp = DateTime.UtcNow, Content = msg }); OnMessageEvent?.Invoke(this, new Ps2EventArgs <string>(msg)); }
protected override void WndProc(ref Message m) { if (m.Msg == WM_CLOSE) { Application.ExitThread(); } OnMessageEvent?.Invoke(ref m); base.WndProc(ref m); }
public TCPServer(IPEndPoint endpoint, OnMessageEvent onMessage) { this.endpoint = endpoint ?? throw new ArgumentNullException("endpoint should not be null"); // Set Unity main thread mainContext = SynchronizationContext.Current; OnMessage = onMessage; }
public static void Unregister(OnMessageEvent e) { foreach (var i in m_Dict_EventRegister) { if (i.Value.Contains(e)) { i.Value.Remove(e); } } }
public static void Register(EMessageID msg_id, OnMessageEvent e) { if (!m_Dict_EventRegister.ContainsKey(msg_id)) { m_Dict_EventRegister.Add(msg_id, new List <OnMessageEvent>()); } if (!m_Dict_EventRegister[msg_id].Contains(e)) { m_Dict_EventRegister[msg_id].Add(e); } }
private async Task Start() { client = new TwitchClient("StylistGraphs", "!", @"oauth:wrkr336oq1airh47j9bpjaggyreuyk", "asmongold"); var onMessageEvent = new OnMessageEvent(); onMessageEvent.Register += onMessage; var commandHandler = new CommandHandler(onMessageEvent); commandHandler.RegisterCommand(new Ping("Ping", "Ping a user")); await Task.Delay(-1); }
private void Update() { if (_messageQueue.Count <= 0) { return; } lock (_messageQueue) { while (_messageQueue.Count > 0) { OnMessageEvent?.Invoke(_messageQueue.Dequeue()); } } }
private void Update() { if (_messageQueue.Count <= 0) return; lock (_messageQueue) { // Notify about new messages while (_messageQueue.Count > 0) { if (OnMessageEvent != null) { OnMessageEvent.Invoke(_messageQueue.Dequeue()); } } } }
private void OnEventReceived(SseEvent @event) { switch (@event.@event) { case "message": OnMessageEvent?.Invoke(@event.jsonData); break; case "subscription": OnSubscriptionEvent?.Invoke(@event.jsonData); break; case "welcome": // do nothing // (used by the SseSocket to detect // connection establishment) break; case "heartbeat": // do nothing break; case "end-connection": // do nothing // (used by the SseSocket to detect // server-requested disconnection) break; default: Debug.LogWarning( "[Unisave] Unknown broadcasting event received: " + @event.@event ); break; } }
internal void FireOnMessageEvent(string type, object message) { OnMessageEvent?.Invoke(type, message); }
//rename stuff private static void UdpMessageRecived(string message) { System.Diagnostics.Debug.WriteLine(message); OnMessageEvent.Invoke(message); }
public virtual void OnLidarMessage(string message, int line) { OnMessageEvent?.Invoke(this, new LidarMessageArgs { Value = message, Line = line }); }
public CommandHandler(OnMessageEvent onMessageEvent) { onMessageEvent.Register += onMessage; }
public TcpCommunicator(string host, int port, OnMessageEvent onMessage) : this(new TcpClient(host, port), onMessage) { }
public TCPServer(IPEndPoint endpoint, OnMessageEvent onMessage, OnEstablishedEvent onEstablished, OnDisconnectedEvent onDisconnected) : this(endpoint, onMessage) { OnEstablished = onEstablished; OnDisconnected = onDisconnected; }