SHARE
TWEET

TNet 3 event subscription

ArenMook Feb 11th, 2016 213 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public abstract class TNEventReceiver : MonoBehaviour
  2. {
  3.     protected virtual void OnError (string msg) { }
  4.     protected virtual void OnConnect (bool success, string msg) { }
  5.     protected virtual void OnDisconnect () { }
  6.     protected virtual void OnJoinChannel (int channelID, bool success, string message) { }
  7.     protected virtual void OnLeaveChannel (int channelID) { }
  8.     protected virtual void OnPlayerJoin (int channelID, Player p) { }
  9.     protected virtual void OnPlayerLeave (int channelID, Player p) { }
  10.     protected virtual void OnRenamePlayer (Player p, string previous) { }
  11.     protected virtual void OnSetServerData (string path, DataNode node) { }
  12.     protected virtual void OnSetChannelData (Channel ch, string path, DataNode node) { }
  13.     protected virtual void OnSetPlayerData (Player p, string path, DataNode node) { }
  14.  
  15.     protected virtual void OnEnable ()
  16.     {
  17.         TNManager.onError += OnError;
  18.         TNManager.onConnect += OnConnect;
  19.         TNManager.onDisconnect += OnDisconnect;
  20.         TNManager.onJoinChannel += OnJoinChannel;
  21.         TNManager.onLeaveChannel += OnLeaveChannel;
  22.         TNManager.onPlayerJoin += OnPlayerJoin;
  23.         TNManager.onPlayerLeave += OnPlayerLeave;
  24.         TNManager.onRenamePlayer += OnRenamePlayer;
  25.         TNManager.onSetServerData += OnSetServerData;
  26.         TNManager.onSetChannelData += OnSetChannelData;
  27.         TNManager.onSetPlayerData += OnSetPlayerData;
  28.     }
  29.  
  30.     protected virtual void OnDisable ()
  31.     {
  32.         TNManager.onError -= OnError;
  33.         TNManager.onConnect -= OnConnect;
  34.         TNManager.onDisconnect -= OnDisconnect;
  35.         TNManager.onJoinChannel -= OnJoinChannel;
  36.         TNManager.onLeaveChannel -= OnLeaveChannel;
  37.         TNManager.onPlayerJoin -= OnPlayerJoin;
  38.         TNManager.onPlayerLeave -= OnPlayerLeave;
  39.         TNManager.onRenamePlayer -= OnRenamePlayer;
  40.         TNManager.onSetServerData -= OnSetServerData;
  41.         TNManager.onSetChannelData -= OnSetChannelData;
  42.         TNManager.onSetPlayerData -= OnSetPlayerData;
  43.     }
  44. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top