protected void OnClearClick(object sender, EventArgs e) { // add some back to message pool foreach (GameMessage msg in DataSource) { MessagePool.PushFree(msg); } // now clear DataSource.Clear(); }
/// <summary> /// Top level handler for a new GameMessage from server /// </summary> /// <param name="Message"></param> protected virtual void HandleGameMessage(GameMessage Message) { /* First determine the type, then call the sub-handlers * Some few messages don't have typed classes yet, * so they appear as GenericGameMessage */ if (!Message.Header.HasEmptyBody) { if (Message is LoginModeMessage) { // always handle in datalayer first to have updated info Data.HandleIncomingLoginModeMessage(Message); // own handlers HandleLoginModeMessage((LoginModeMessage)Message); } else if (Message is GameModeMessage) { // always handle in datalayer first to have updated info Data.HandleIncomingGameModeMessage(Message); // let roomfile handle message for changes if (CurrentRoom != null) { CurrentRoom.HandleGameModeMessage((GameModeMessage)Message); } // own handlers HandleGameModeMessage((GameModeMessage)Message); } // GenericGameMessage else { // just for logging purposes Data.HandleIncomingGenericGameMessage(Message); } // possibly push message back to pool (if logging not enabled) if (!Data.LogIncomingMessages) { MessagePool.PushFree(Message); } } }