/// <summary> Redirect item from client to all other connected clients </summary> public void RedirectItem(int sourceConnectionID, Item item) { ItemMessage addItemMessage = new ItemMessage(); addItemMessage.item = item; SendToAllExcept(sourceConnectionID, NetworkMessageType.AddItem, addItemMessage); }
/// <summary> Event for AddItem message from client to server </summary> void OnAddItem(NetworkMessage addItemMsg) { #if DEBUG Debugging.PrintScreen("Got item from client"); #endif ItemMessage itemMessage = addItemMsg.ReadMessage <ItemMessage>(); Item item = itemMessage.item; RedirectItem(addItemMsg.conn.connectionId, item); }
/// <summary> Event for single item packet message </summary> void OnAddItem(NetworkMessage addItemMsg) { ItemMessage itemMsg = addItemMsg.ReadMessage <ItemMessage>(); if (itemMsg.item == null) { #if DEBUG Debugging.PrintScreen("Received item is not valid"); #endif return; } #if DEBUG Debugging.PrintScreen("Received package with one item"); #endif items.Add(itemMsg.item); }