Example #1
0
 /// <summary>
 ///     Invoked when a packet is recieved by the network manager.
 /// </summary>
 /// <param name="sender">Connection that packet was connected from.</param>
 /// <param name="packet">Packet that was recieved.</param>
 void PacketRecieved(object sender, NetworkPacket packet)
 {
     foreach (ScriptProcess process in VirtualMachine.GlobalInstance.Processes)
     {
         NetworkPacketScriptObject packetSO = new NetworkPacketScriptObject(packet);
         NetworkConnectionScriptObject connectionSO = new NetworkConnectionScriptObject(sender as NetworkConnection);
         foreach (ScriptThread thread in process.Threads)
         {
             thread.PassParameter(connectionSO);
             thread.PassParameter(packetSO);
             thread.InvokeFunction("OnPacketRecieved", true, false);
         }
     }
 }
Example #2
0
 /// <summary>
 ///     Invoked when a client disconnects from the network manager.
 /// </summary>
 /// <param name="sender">Connection that client disconnected from.</param>
 /// <param name="client">Client that disconnected.</param>
 void ClientDisconnected(object sender, NetworkClient client)
 {
     foreach (ScriptProcess process in VirtualMachine.GlobalInstance.Processes)
     {
         NetworkClientScriptObject clientSO = new NetworkClientScriptObject(client);
         NetworkConnectionScriptObject connectionSO = new NetworkConnectionScriptObject(sender as NetworkConnection);
         foreach (ScriptThread thread in process.Threads)
         {
             thread.PassParameter(connectionSO);
             thread.PassParameter(clientSO);
             thread.InvokeFunction("OnClientDisconnected", true, false);
         }
     }
 }