public void Dispose() { msgTypeGenerator.DeallocateValue(msgType); msgTypeGenerator = null; // attempt to unregister the message NetworkServer.UnregisterHandler(msgType); // dispose of this to get rid of cycle reference Master = null; }
public void SetAutomaticMsgType(byte scopeIdentifier, ShortGenerator msgTypeGen) { if (msgTypeGenerator != null) { throw new Exception(string.Format("The Scope {0} has already been assigned a MsgType value", GetType())); } this.scopeIdentifier = scopeIdentifier; msgType = msgTypeGen.AllocateValue(); msgTypeGenerator = msgTypeGen; // register with the Server's Scope msgType NetworkServer.RegisterHandler(msgType, ProcessPeerMessage); }
public void SetManualMsgType(byte scopeIdentifier, ShortGenerator msgTypeGen, short manualMsgType) { if (msgTypeGenerator != null) { throw new Exception(string.Format("The Scope {0} has already been assigned a MsgType value", GetType())); } this.scopeIdentifier = scopeIdentifier; // use up the value manually in the generator msgTypeGen.AllocateManualValue(manualMsgType); msgType = manualMsgType; msgTypeGenerator = msgTypeGen; }