/// <summary> /// Starts the client for a match in online mode /// </summary> /// <param name="msgTypeToMsgHandler">Message handlers provided from the game</param> private void StartOnlineClient(Dictionary <Type, IMessageHandlerCommandClient> msgTypeToMsgHandler) { messageHandler = new MatchMessageHandler(logger, EventHandler, msgTypeToMsgHandler); var connectioninfo = new ClientConnectionInfo(persistentData.port, persistentData.ip); client = new Client(this, connectioninfo, messageHandler, persistentData, logger, this, config); }
new void Start() { base.Start(); _messageHandler = GetComponentInChildren <MatchMessageHandler>(); _matchTcp = GetComponent <MatchTCPConnection>(); _matchUdp = GetComponent <UDPConnection>(); _messageHandler.NewMatch(); }
/// <summary> /// Removes the first found listener (if any) matching to the supplied handler delegate. /// </summary> /// <typeparam name="T">Message type to look for.</typeparam> /// <param name="handler">Handler to remove.</param> /// <returns>True if a listener was removed, false if none found.</returns> public bool RemoveListener <T>(MatchMessageHandler <T> handler) where T : MatchMessage { for (int i = 0; i < listeners.Count; i++) { MatchMessageListener listenerEntry = listeners[i]; if (listenerEntry.MessageType == typeof(T) && (MatchMessageHandler <T>)listenerEntry.Handler == handler) { listeners.Remove(listenerEntry); return(true); } } return(false); }
private void Awake() { i = this; }
/// <summary> /// Creates a listener for a type of message that calls the supplied handler delegate when this message type is received. /// </summary> /// <typeparam name="T">Message type to add.</typeparam> /// <param name="handler">Handler to call when this message type is received.</param> public void CreateListener <T>(MatchMessageHandler <T> handler) where T : MatchMessage { listeners.Add(new MatchMessageListener(typeof(T), handler)); }