private void HandleInvokeMethodStart(IEventData eventData, SendParameters sendParameters) { string method = (string)eventData.Parameters[(byte)ServerToServerParameterCode.Method]; object[] arguments = eventData.Parameters[(byte)ServerToServerParameterCode.Arguments] as object[]; string sourceServerID = eventData.Parameters[(byte)ServerToServerParameterCode.SourceServer] as string; byte targetServetType = (byte)eventData.Parameters[(byte)ServerToServerParameterCode.TargetServer]; var mtd = m_Invoker.GetType().GetMethod(method); S2SInvokeMethodEnd end = new S2SInvokeMethodEnd { method = method, sourceServerID = sourceServerID, targetServerType = targetServetType, }; if (mtd != null) { object result = mtd.Invoke(m_Invoker, arguments); end.callSuccess = true; end.result = result; } else { end.callSuccess = false; end.result = null; } EventData retEvent = new EventData((byte)S2SEventCode.InvokeMethodEnd, end); SendEvent(retEvent, new SendParameters()); }
protected override void OnEvent(IEventData eventData, SendParameters sendParameters) { try { switch ((S2SEventCode)eventData.Code) { case S2SEventCode.PUTMaiTransactionEnd: { HandlePutMailTransactionEnd(eventData, sendParameters); } break; case S2SEventCode.InvokeMethodStart: { string method = (string)eventData.Parameters[(byte)ServerToServerParameterCode.Method]; object[] arguments = eventData.Parameters[(byte)ServerToServerParameterCode.Arguments] as object[]; string sourceServiceId = eventData.Parameters[(byte)ServerToServerParameterCode.SourceServer] as string; byte targetServerType = (byte)eventData.Parameters[(byte)ServerToServerParameterCode.TargetServer]; MethodInfo methodInfo = methodInvoker.GetType().GetMethod(method); S2SInvokeMethodEnd end = new S2SInvokeMethodEnd { method = method, sourceServerID = sourceServiceId, targetServerType = targetServerType }; if (methodInfo != null) { object result = methodInfo.Invoke(methodInvoker, arguments); end.callSuccess = true; end.result = result; } else { end.callSuccess = false; end.result = null; } EventData returnedEventData = new EventData((byte)S2SEventCode.InvokeMethodEnd, end); SendEvent(returnedEventData, new SendParameters()); } break; } } catch (Exception exception) { log.InfoFormat(exception.Message); log.InfoFormat(exception.StackTrace); } //S2S operations with passes not applicable more /* * try { * switch((S2SEventCode)eventData.Code) { * case S2SEventCode.GETInventoryItemEnd: * { * GETInventoryItemTransactionEnd end = new GETInventoryItemTransactionEnd(eventData); * switch((TransactionSource)end.transactionSource) { * case TransactionSource.PassManager: * { * application.passManager.getTransactionPool.HandleTransaction(end); * } * break; * default: * { * log.InfoFormat("Login Master Peer unhandled get transaction source = {0} [red]", (TransactionSource)end.transactionSource); * } * break; * } * } * break; * case S2SEventCode.PUTInventoryItemEnd: * { * PUTInventoryItemTransactionEnd end = new PUTInventoryItemTransactionEnd(eventData); * switch((TransactionSource)end.transactionSource) { * case TransactionSource.PassManager: * { * application.passManager.putTransactionPool.HandleTransaction(end); * } * break; * default: * { * log.InfoFormat("Login Master Peer unhandled put transaction source = {0} [red]", (TransactionSource)end.transactionSource); * } * break; * } * } * break; * } * } catch(Exception exception) { * log.InfoFormat(exception.Message); * log.InfoFormat(exception.StackTrace); * }*/ }
protected override void OnEvent(IEventData eventData, SendParameters sendParameters) { try { switch ((S2SEventCode)eventData.Code) { default: { if (log.IsDebugEnabled) { log.DebugFormat("Received unknown event code {0}", eventData.Code); } break; } case S2SEventCode.UpdateShipModel: { HandleUpdateShipModelEvent(eventData); break; } case S2SEventCode.UpdateCharacter: { HandleUpdateCharacterEvent(eventData); break; } case S2SEventCode.GETInventoryItemEnd: { GETInventoryItemTransactionEnd end = new GETInventoryItemTransactionEnd(eventData); switch ((TransactionSource)end.transactionSource) { case TransactionSource.Store: { application.Stores.inventoryGETPool.HandleTransaction(end); log.Info("GET transaction handled"); break; } case TransactionSource.Bank: { application.Clients.HandleTransaction(end); log.Info("bank add transaction returned...."); break; } } break; } case S2SEventCode.GETInventoryItemsEnd: { GETInventoryItemsTransactionEnd end = new GETInventoryItemsTransactionEnd(eventData); switch ((TransactionSource)end.transactionSource) { case TransactionSource.Mail: { application.Mail.inventoryItemsGETPool.HandleTransaction(end); log.Info("get transaction handled"); break; } } break; } case S2SEventCode.PUTInventoryItemEnd: { HandlePUTInventoryTransactionEnd(eventData, sendParameters); break; } //called when from login inap store we put item to character mail case S2SEventCode.PUTMailTransactionStart: { HandlePutMailTransactionStart(eventData, sendParameters); } break; case S2SEventCode.InvokeMethodStart: { string method = (string)eventData.Parameters[(byte)ServerToServerParameterCode.Method]; object[] arguments = eventData.Parameters[(byte)ServerToServerParameterCode.Arguments] as object[]; string sourceServerID = eventData.Parameters[(byte)ServerToServerParameterCode.SourceServer] as string; byte targetServetType = (byte)eventData.Parameters[(byte)ServerToServerParameterCode.TargetServer]; var mtd = mInvoker.GetType().GetMethod(method); S2SInvokeMethodEnd end = new S2SInvokeMethodEnd { method = method, sourceServerID = sourceServerID, targetServerType = targetServetType, }; if (mtd != null) { object result = mtd.Invoke(mInvoker, arguments); end.callSuccess = true; end.result = result; } else { end.callSuccess = false; end.result = null; } EventData retEvent = new EventData((byte)S2SEventCode.InvokeMethodEnd, end); SendEvent(retEvent, new SendParameters()); break; } case S2SEventCode.InvokeMethodEnd: { bool success = (bool)eventData.Parameters[(byte)ServerToServerParameterCode.Success]; object result = eventData.Parameters[(byte)ServerToServerParameterCode.Result] as object; string method = eventData.Parameters[(byte)ServerToServerParameterCode.Method] as string; NebulaCommon.ServerType serverType = (NebulaCommon.ServerType)(byte) eventData.Parameters[(byte)ServerToServerParameterCode.TargetServer]; if (success) { log.InfoFormat("method {0} successfully called on server {1}", method, serverType); } else { log.InfoFormat("fail call method {0} on server {1}", method, serverType); } } break; } }catch (Exception ex) { log.Error(ex); } }