/// <summary> /// Fire the events registered for this packet type asynchronously /// </summary> /// <param name="incomingPacket">The incoming packet</param> internal void BeginRaiseEvent(IncomingPacket incomingPacket) { PacketCallback callback; if (m_eventTable.TryGetValue(incomingPacket.Packet.Type, out callback) && callback != null) { PacketCallbackWrapper wrapper = new PacketCallbackWrapper { Callback = callback, IncomingPacket = incomingPacket }; m_scheduler.FireAndForget(PacketDelegate, wrapper); } else { m_log.Debug("No handler registered for packet " + incomingPacket.Packet.Type); } }
private void HandleUseCircuitCode(UDPPacketBuffer buffer, UseCircuitCodePacket packet, int now) { IPEndPoint remoteEndPoint = (IPEndPoint)buffer.RemoteEndPoint; LLAgent agent; if (m_clients.TryGetValue(packet.CircuitCode.ID, out agent)) { // Update the remoteEndPoint for this agent m_clients.UpdateKey2(agent.ID, agent.RemoteEndPoint, remoteEndPoint); agent.RemoteEndPoint = remoteEndPoint; // Acknowledge the UseCircuitCode packet SendAckImmediate(remoteEndPoint, packet.Header.Sequence); // Fire any callbacks registered for this packet IncomingPacket incomingPacket = new IncomingPacket(agent, packet, now); incomingPacket.StartedHandling = now; PacketEvents.BeginRaiseEvent(incomingPacket); } else { m_log.Error("Failed to add new client " + packet.CircuitCode.ID + " connecting from " + remoteEndPoint); } }