public void ClientRPCEx(SendInfo sendInfo, Connection sourceConnection, ERPCMethodType method) { if (NetworkManager.BaseNetworkServer.IsConnected() && this.ClientRPCStart(sourceConnection, method)) { this.ClientRPCSend(sendInfo); } }
public static void Run(uint uid, ERPCMethodType method, Message message) { if (ListRPCMethods.TryGetValue(method, out var methods)) { if (BaseNetworkable.ListNetworkables.TryGetValue(uid, out var networkable)) { var type = networkable.GetType(); var rpcmethod = methods.FirstOrDefault(p => p.Key == type || p.Key.IsSubclassOf(type)).Value; if (rpcmethod != null) { try { using (new TimeDebugger($"{method}", 0.001f)) { rpcmethod.Invoke(networkable, message); } } catch (Exception ex) { ConsoleSystem.LogError("[Data.Base.Network Run] Exception: " + ex.Message + System.Environment.NewLine + ex.StackTrace); } } } else { ConsoleSystem.LogWarning("[Data.Base.Network Run] Dont have networkable uid: " + uid); } } else { ConsoleSystem.LogWarning("[Data.Base.Network Run] Dont have released method: " + method + " from " + BaseNetworkable.ListNetworkables?[uid]); } }
private bool ClientRPCStart(Connection sourceConnection, ERPCMethodType method) { if (NetworkManager.BaseNetworkServer.write.Start()) { NetworkManager.BaseNetworkServer.write.PacketID(Message.Type.RPCMessage); NetworkManager.BaseNetworkServer.write.UInt32(this.UID); NetworkManager.BaseNetworkServer.write.UInt32((uint)method); NetworkManager.BaseNetworkServer.write.UInt64(sourceConnection?.userid ?? 0UL); return(true); } return(false); }
public void ClientRPCEx <T1, T2, T3, T4>(SendInfo sendInfo, Connection sourceConnection, ERPCMethodType method, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { if (NetworkManager.BaseNetworkServer.IsConnected() && this.ClientRPCStart(sourceConnection, method)) { this.ClientRPCWrite <T1>(arg1); this.ClientRPCWrite <T2>(arg2); this.ClientRPCWrite <T3>(arg3); this.ClientRPCWrite <T4>(arg4); this.ClientRPCSend(sendInfo); } }
public RPCMethodAttribute(ERPCMethodType type) { this.Type = type; }