private static void OnJoin(Message msg) { JoinEvent?.Invoke(new SystemMsgEventArgs() { msg = msg }); }
private void OnMessageReceived(object sender, MessageReceivedEventArgs e) { var message = JsonConvert.DeserializeObject <Message>(e.Message); switch (message.Header) { case "Join": var joinRes = JsonConvert.DeserializeObject <JoinRes>(message.Body); JoinEvent?.Invoke(this, new JoinEventArgs { JoinRes = joinRes }); break; case "Hand": var handRes = JsonConvert.DeserializeObject <HandRes>(message.Body); HandEvent?.Invoke(this, new HandEventArgs { HandRes = handRes }); break; case "Tsumo": var tsumoRes = JsonConvert.DeserializeObject <TsumoRes>(message.Body); TsumoEvent?.Invoke(this, new TsumoEventArgs { TsumoRes = tsumoRes }); break; case "Dahai": var dahaiRes = JsonConvert.DeserializeObject <DahaiRes>(message.Body); DahaiEvent?.Invoke(this, new DahaiEventArgs { DahaiRes = dahaiRes }); break; case "Agari": var agariRes = JsonConvert.DeserializeObject <AgariRes>(message.Body); AgariEvent?.Invoke(this, new AgariEventArgs { AgariRes = agariRes }); break; default: break; } }
private void OnMessageReceived(object sender, MessageReceivedEventArgs e) { var message = JsonConvert.DeserializeObject <Message>(e.Message); switch (message.Header) { case "Join": var joinReq = JsonConvert.DeserializeObject <JoinReq>(message.Body); JoinEvent?.Invoke(this, new JoinEventArgs(joinReq)); ResponseJoin(); Start(); break; case "Hand": var handReq = JsonConvert.DeserializeObject <HandReq>(message.Body); ResponseHand(); break; case "Tsumo": var tsumoReq = JsonConvert.DeserializeObject <TsumoReq>(message.Body); ResponseTsumo(); break; case "Dahai": var dahaiReq = JsonConvert.DeserializeObject <DahaiReq>(message.Body); ResponseDahai(dahaiReq.Index); break; case "Agari": var agariReq = JsonConvert.DeserializeObject <AgariReq>(message.Body); ResponseAgari(); break; default: break; } }
private void IRCInputProcedure(System.IO.TextReader input, System.Net.Sockets.NetworkStream networkStream) { while (!stopThreads) { if (networkStream.DataAvailable) { buffer = input.ReadLine(); Debug.Log("message recieved: " + buffer); if (buffer.Contains("PRIVMSG #")) { lock (recievedMsgs) { recievedMsgs.Add(buffer); } } else if (buffer.Contains("JOIN")) { channelName = buffer.Split('#')[1]; JoinedChannelEvent.Invoke(channelName); } //send pong reply to ping messages if (buffer.StartsWith("PING ")) { SendCommand(buffer.Replace("PING", "PONG")); } //After server sends 001 command, we can join the cahnnel if (buffer.Split(' ')[1] == "001") { joinable = true; } } } }
public void JoinGame() { joinEvent?.Invoke(game.uniqueId); }
protected virtual void RaiseJoinEvent(TokenEventArgs e) { JoinEvent?.Invoke(this, e); }