public NWEvent(NWServerAction serverAction) { if (serverAction.ActionsParams.ContainsKey((int)eEventKeys.Type)) { Type = (NWEventType)serverAction.ActionsParams[(int)eEventKeys.Type]; } if (serverAction.ActionsParams.ContainsKey((int)eEventKeys.Data)) { Data = (Hashtable)serverAction.ActionsParams[(int)eEventKeys.Data]; } }
void INWNetworking.SendAction(NWServerAction serverAction) { _queuedActions.Add(serverAction); }
void OnEventHandler(byte eventCode, object content, int senderId) { Debug.Log("got event: " + eventCode + " content: " + content + " senderId: " + senderId); if (OnReciveAction != null) { Hashtable[] actionsList = (Hashtable[])content; for (int i=0; i < actionsList.Length; i++) { Hashtable actionHash = (Hashtable)actionsList[i]; NWServerAction serverAction = new NWServerAction(actionHash); OnReciveAction(serverAction); } } }
public NWServerAction ToServerAction() { Hashtable hash = new Hashtable(); hash.Add((int)eEventKeys.Type, Type); if (Data != null) { hash.Add((int)eEventKeys.Data, Data); } NWServerAction serverAction = new NWServerAction(ServerActionType.GameplayEvent, hash); return serverAction; }