public static async Task CallHandler(byte ipcMessage, Stream ipcMessageData, IPCSession session) { var message = (IPCMessage)ipcMessage; Tuple <MethodInfo, Type> data; if (messageHandlers.TryGetValue(message, out data)) { var handlerObj = Activator.CreateInstance(data.Item2, ipcMessage, ipcMessageData) as IPCPacket; await Task.Run(() => data.Item1.Invoke(null, new object[] { handlerObj, session })); } else { var msgName = Enum.GetName(typeof(IPCMessage), message); if (msgName == null) { Log.Message(LogTypes.Warning, $"Received unknown ipc message '0x{message:X}'."); } else { Log.Message(LogTypes.Warning, $"Handler for '{msgName} (0x{message:X}) not implemented."); } } }
public static async Task CallHandler(byte ipcMessage, Stream ipcMessageData, IPCSession session) { var message = (IPCMessage)ipcMessage; Tuple<MethodInfo, Type> data; if (messageHandlers.TryGetValue(message, out data)) { var handlerObj = Activator.CreateInstance(data.Item2, ipcMessage, ipcMessageData) as IPCPacket; await Task.Run(() => data.Item1.Invoke(null, new object[] { handlerObj, session })); } else { var msgName = Enum.GetName(typeof(IPCMessage), message); if (msgName == null) Log.Message(LogTypes.Warning, $"Received unknown ipc message '0x{message:X}'."); else Log.Message(LogTypes.Warning, $"Handler for '{msgName} (0x{message:X}) not implemented."); } }
public static void AddConsoleClient(string alias, IPCSession session) => consolePipeClients.Add(alias, session);