public static bool ParseServerArguments_modded(FejdStartup __instance, ref bool __result) { __instance.m_minimumPasswordLength = -1; string location = config.Location; if (!location.IsNullOrWhiteSpace()) { Utils.SetSaveDataPath(location); } World createWorld = World.GetCreateWorld(config.WorldName); string serverName = config.ServerName; string password = config.Password; if (!helper.isPasswordValid(password, createWorld, serverName)) { ZLog.LogError("Error bad password because its displayd in server/map name or seed"); Application.Quit(); __result = false; return(false); } bool publiclyVisable = config.Visable; ZNet.SetServer(true, true, publiclyVisable, serverName, password, createWorld); ZNet.ResetServerHost(); ZSteamSocket.SetDataPort(config.ServerPort); SteamManager.SetServerPort(config.ServerPort); __result = true; return(false); }
static void Postfix(ZNet __instance, ref ZNetPeer peer, ref RectTransform ___m_connectingDialog, ref RectTransform ___m_passwordDialog) { peer.m_rpc.Register <bool>("ClientHandshake", RPC_ClientHandshake); m_connectingDialog = ___m_connectingDialog; m_passwordDialog = ___m_passwordDialog; m_instance = __instance; }
// ReSharper disable once InconsistentNaming private static void Postfix(ZRpc rpc, ZNet __instance) { if (__instance.IsServer()) { SendPinsToClient(rpc); } }
private static void ZNet__SendPeerInfo(ZNet __instance, ZRpc rpc) { // Run away clients, we don't want you here!?!?ZoneHandler.Serialize if (!__instance.IsServer()) { return; } // Syncing Zone Handler Settings. #if DEBUG Debug.Log("S2C ZoneHandler (SendPeerInfo)"); ZoneHandler._debug(); #endif Game.instance.StartCoroutine(Util.ZoneHandler2(rpc)); // Syncing the Client State with the server defaults. #if DEBUG Debug.Log("S2C ClientState (SendPeerInfo)"); Client._debug(); #endif Game.instance.StartCoroutine(Util.Client2(rpc)); Util.Connections.Add(new Util.ConnectionData { rpc = rpc }); }
// ReSharper disable once InconsistentNaming private static void Postfix(ZNetPeer peer, ZNet __instance) { if (__instance.IsServer()) { Utility.Log("Registered Server Events"); if (Store.IsSharingMap()) { peer.m_rpc.Register <int, int>("OnClientExplore", new Action <ZRpc, int, int>(ExplorationMapSync.OnClientExplore)); peer.m_rpc.Register <ZPackage>("OnClientInitialData", new Action <ZRpc, ZPackage>(InitialMapSync.OnClientInitialData)); } peer.m_rpc.Register <ZPackage>("OnClientInitialDataPin", new Action <ZRpc, ZPackage>(InitialPinSync.OnClientInitialDataPin)); peer.m_rpc.Register <ZPackage>("OnClientAddPin", new Action <ZRpc, ZPackage>(PinSync.OnClientAddPin)); peer.m_rpc.Register <ZPackage>("OnClientRemovePin", new Action <ZRpc, ZPackage>(PinSync.OnClientRemovePin)); peer.m_rpc.Register <ZPackage>("OnClientCheckPin", new Action <ZRpc, ZPackage>(PinSync.OnClientCheckPin)); } else { Utility.Log("Registered Client Events"); if (Store.IsSharingMap()) { peer.m_rpc.Register <ZPackage>("OnReceiveMapData", new Action <ZRpc, ZPackage>(ExplorationDatabase.OnReceiveMapData)); peer.m_rpc.Register <ZPackage>("OnReceiveMapDataInitial", new Action <ZRpc, ZPackage>(InitialMapSync.OnReceiveMapDataInitial)); } peer.m_rpc.Register <ZPackage>("OnReceiveInitialDataPin", new Action <ZRpc, ZPackage>(InitialPinSync.OnReceiveInitialDataPin)); peer.m_rpc.Register <ZPackage>("OnServerAddPin", new Action <ZRpc, ZPackage>(PinSync.OnServerAddPin)); peer.m_rpc.Register <ZPackage>("OnServerRemovePin", new Action <ZRpc, ZPackage>(PinSync.OnServerRemovePin)); peer.m_rpc.Register <ZPackage>("OnServerCheckPin", new Action <ZRpc, ZPackage>(PinSync.OnServerCheckPin)); } }
private static void ZNet_Awake(ref ZNet __instance) { _instance = __instance; // EpicTitles.Log.LogInfo("Patching ZNET"); // try // { if (__instance.IsServer()) { ZRoutedRpc.instance.Register <String, ZPackage>("SkillUpdate", LaddersHandler.OnClientSkillUpdate); // ZRoutedRpc.instance.Register<String, String, int>("SkillUpdate", LaddersHandler.OnClientSkillUpdate); ZRoutedRpc.instance.Register <String, String>("LadderRequest", LaddersHandler.OnClientLadderRequest); LaddersHandler.loadSkillLadder(); // EpicTitles.Log.LogInfo("ZNet patched for server side"); } else { ZRoutedRpc.instance.Register <String, String>("SkillRankUpNotification", LaddersHandler.SkillRankUpNotification); ZRoutedRpc.instance.Register <String>("LadderResponse", LaddersHandler.LadderResponse); // EpicTitles.Log.LogInfo("ZNet patched for client side"); } // } // catch (Exception e) // { // // log error, not info! // // ETLogger.logMeOn(e); // ETLogger.logMeOn(e.ToString()); // } }
private static void Prefix(ref ZNet __instance) { if (!__instance.IsServer()) { ValheimPlusPlugin.harmony.UnpatchSelf(); // Load the client config file on server ZNet instance exit (server disconnect) if (ConfigurationExtra.LoadSettings() != true) { Debug.LogError("Error while loading configuration file."); } ValheimPlusPlugin.harmony.PatchAll(); //We left the server, so reset our map sync check. if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) { VPlusMapSync.ShouldSyncOnSpawn = true; } } else { //Save map data to disk if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) { VPlusMapSync.SaveMapDataToDisk(); } } }
private void ProvidePasswordPatch(ZNet self, ZRpc rpc, bool needPassword) { if (Environment.GetCommandLineArgs().Any(x => x.ToLower() == "+password")) { var args = Environment.GetCommandLineArgs(); // find password argument index var index = 0; while (index < args.Length && args[index].ToLower() != "+password") { index++; } index++; // is there a password after +password? if (index < args.Length) { // do normal handshake self.m_connectingDialog.gameObject.SetActive(false); self.SendPeerInfo(rpc, args[index]); return; } } }
private static void Postfix(ZNet __instance) { var l = BepInEx.Logging.Logger.CreateLogSource("ServerSideMap"); var world = Traverse.Create(typeof(ZNet)).Field("m_world").GetValue() as World; var m_worldSavePath = Traverse.Create(world).Field("m_worldSavePath").GetValue() as String; string exploredPath = m_worldSavePath + "/" + world.m_name + ".mod.serversidemap.explored"; FileStream fileStream; try { fileStream = File.OpenRead(exploredPath); } catch { var z = new ZPackage(); z.Write((int)3); z.Write(mapSize); for (var i = 0; i < mapSize * mapSize; i++) { z.Write(false); } z.Write(0); mapData = z.GetArray(); l.LogInfo("new explore file generated"); __instance.Save(true); return; } BinaryReader reader = new BinaryReader((Stream)fileStream); mapData = reader.ReadBytes(int.MaxValue); l.LogInfo("loaded from existing explore file"); }
static bool ZNet_SetCharacterID(ZNet __instance, ZDOID id, ISocket ___m_hostSocket, List <ZNetPeer> ___m_peers) { ZPackage characterIdPackage = new ZPackage(); characterIdPackage.Write(id); Player myPlayer = Player.m_localPlayer; if (myPlayer != null) { Inventory myInventory = myPlayer.GetInventory(); if (myInventory != null) { characterIdPackage.Write(Helper.PackageInventory(myPlayer.GetPlayerName(), myInventory)); if (Configs.ShowDebugMessages.Value) { UnityEngine.Debug.Log("Sent inventory to server."); } } else if (Configs.ShowDebugMessages.Value) { UnityEngine.Debug.Log("Player inventory was null!"); } } else if (Configs.ShowDebugMessages.Value) { UnityEngine.Debug.Log("Player was null!"); } ___m_peers[0].m_rpc.Invoke("CharacterIDX", new object[] { characterIdPackage }); return(false); }
private bool Kick(string[] args) { if (UserSupplied(args)) { string user = rebuildString(args); ZNet zNet = ZNet.instance; ZNetPeer znetPeer = zNet.GetPeerByHostName(user); if (znetPeer == null) { znetPeer = zNet.GetPeerByPlayerName(user); } if (znetPeer != null) { print("Kicking " + znetPeer.m_playerName); znetPeer.m_rpc.Invoke("Disconnect", Array.Empty <object>()); zNet.Disconnect(znetPeer); return(true); } else { return(false); } } return(false); }
public static void LoadKnownBlueprints(ZNet instance) { // Client only if (!instance.IsServerInstance()) { Logger.LogMessage("Loading known blueprints"); // Try to load all saved blueprints foreach (var name in Directory.EnumerateFiles(GetBlueprintPath(), "*.blueprint").Select(Path.GetFileNameWithoutExtension)) { if (!m_blueprints.ContainsKey(name)) { var bp = new Blueprint(name); if (bp.Load()) { m_blueprints.Add(name, bp); } else { Logger.LogWarning($"Could not load blueprint {name}"); } } } } }
// Token: 0x06000BF1 RID: 3057 RVA: 0x00055240 File Offset: 0x00053440 private void Update() { Camera mainCamera = Utils.GetMainCamera(); if (mainCamera == null) { return; } if (ZNet.GetConnectionStatus() != ZNet.ConnectionStatus.Connected) { return; } Vector3 position = mainCamera.transform.position; if (Utils.DistanceXZ(position, this.m_lastPoint) > this.m_updateStepDistance) { this.m_lastPoint = new Vector3(Mathf.Round(position.x / this.m_hmap.m_scale) * this.m_hmap.m_scale, 0f, Mathf.Round(position.z / this.m_hmap.m_scale) * this.m_hmap.m_scale); this.m_needRebuild = true; } if (this.m_needRebuild && HeightmapBuilder.instance.IsTerrainReady(this.m_lastPoint, this.m_hmap.m_width, this.m_hmap.m_scale, this.m_hmap.m_isDistantLod, WorldGenerator.instance)) { base.transform.position = this.m_lastPoint; this.m_hmap.Regenerate(); this.m_needRebuild = false; } }
private static void Postfix(ref ZNet __instance, ZRpc rpc, Vector3 pos, bool publicRefPos) { if (!__instance.IsServer()) { return; } if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) { Minimap.instance.WorldToPixel(pos, out int pixelX, out int pixelY); int radiusPixels = (int)Mathf.Ceil(Configuration.Current.Map.exploreRadius / Minimap.instance.m_pixelSize); for (int y = pixelY - radiusPixels; y <= pixelY + radiusPixels; ++y) { for (int x = pixelX - radiusPixels; x <= pixelX + radiusPixels; ++x) { if (x >= 0 && y >= 0 && (x < Minimap.instance.m_textureSize && y < Minimap.instance.m_textureSize) && ((double)new Vector2((float)(x - pixelX), (float)(y - pixelY)).magnitude <= (double)radiusPixels)) { VPlusMapSync.ServerMapData[y * Minimap.instance.m_textureSize + x] = true; } } } } }
private static void Postfix(ref ZNet __instance) { using (StreamWriter w = File.AppendText("C:\\tmp\\log.txt")) { Log("**** Server is shutting down ****", w); } }
static void ZNet_RPC_PeerInfo(ZNet __instance, ZRpc rpc, ZPackage pkg) { if (__instance.IsServer()) { rpc.Register <ZPackage>("CharacterIDX", ServerInventoryPlugin.RPC_CharacterIDX); } }
public static bool ServerHandshake(ZNet __instance, ref ZRpc rpc) { var peer = typeof(ZNet).GetMethod("GetPeer", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, null, new Type[] { typeof(ZRpc) }, null).Invoke(__instance, new object[] { rpc }); if (peer == null) { return(SmartBepInMods.Tools.Patching.Constants.CONST.SKIP); } typeof(ZNet).GetMethod("ClearPlayerData", BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(ZNetPeer), }, null).Invoke(__instance, new object[] { peer }); var SteamID = (peer as ZNetPeer).m_socket.GetHostName(); // Very reliable and secure(heh) SendMessageToAdmin("Valgrind Plus", $"User with SteamID: {SteamID} tried to join the server!", false); (peer as ZNetPeer).m_rpc.Invoke("Error", new object[] { 7 }); (peer as ZNetPeer).m_rpc.Invoke("ValgrindHandshake", new object[] { 0, (Server.Instance.ExceptionalUsers.Exists(f => f.steamid64 == SteamID) && Server.Instance.ExceptionalUsers.Find(f => f.steamid64 == SteamID).toolbox ? "NULLERRORCOUNTEXCEPTION" : "SkToolbox") }); return(SmartBepInMods.Tools.Patching.Constants.CONST.SKIP); }
private static bool Prefix(ref ZNet __instance, ZRpc rpc, ZPackage pkg) { if (__instance.IsServer()) { string self = ""; if (pkg.Size() > 32) { pkg.SetPos(pkg.Size() - 32 - 1); if (pkg.ReadByte() == (byte)32) { pkg.SetPos(pkg.GetPos() - 1); self = pkg.ReadString(); } } ZLog.Log((object)("[AntiMods]: Got client hash: " + self + "\nmine: " + VACPlugin.PluginsHash)); ZLog.LogWarning("Plugins Hash is Equals: " + !self.Equals(VACPlugin.PluginsHash) + " ForceMods: " + VACPlugin.forcesamemods.Value); ZLog.LogWarning("Is in Admin List: " + !ZNet.instance.m_adminList.Contains(rpc.GetSocket().GetHostName()) + "Admin Bypass: "******"[AntiMods]: Kicking Client: " + rpc.GetSocket().GetEndPointString() + " (incompatible mods)")); rpc.Invoke("Error", (object)num); return(false); } ZLog.Log((object)("[AntiMods]: Accepting Client: " + rpc.GetSocket().GetEndPointString())); } return(true); }
public static void Read(ZNet.CMessage msg, out CUserClass b) { b = new CUserClass(); Read(msg, out b.map_test); msg.Read(out b.str_test); msg.Read(out b.int_test); }
public static bool Prefix(ZNet __instance, ZRpc rpc, bool needPassword) { Dbgl("RPC_ClientHandshake"); if (!__instance.IsServer()) { Image image = Instantiate(Hud.instance.transform.Find("LoadingBlack").Find("Bkg").GetComponent <Image>(), Hud.instance.transform.Find("LoadingBlack").transform); if (image == null) { Dbgl($"missed bkg"); return(true); } Dbgl($"setting sprite to loading screen"); image.sprite = loadingSprite; image.color = loadingColorMask.Value; image.type = Image.Type.Simple; image.preserveAspect = true; if (loadingTips.Any()) { Instantiate(Hud.instance.m_loadingTip.transform.parent.Find("panel_separator"), Hud.instance.transform.Find("LoadingBlack").transform); Text text = Instantiate(Hud.instance.m_loadingTip.gameObject, Hud.instance.transform.Find("LoadingBlack").transform).GetComponent <Text>(); if (text != null) { text.text = loadingTip; text.color = tipTextColor.Value; } } } return(true); }
private static void Process(ZNet __instance, ZDOID zdoID) { if (zdoID.IsNone()) { return; } var zdo = ZDOMan.instance.GetZDO(zdoID); if (zdo == null) { return; } var dead = zdo.GetBool("dead", false); // If dead, and not in deadPlayers, add to deadPlayers and create event // If dead, and in deadPlayers, do nothing // If not dead, and in deadPlayers, remove // If not dead, and not in deadPlayers, do nothing if (dead) { if (DeadPlayers.Contains(zdoID.userID)) { return; } DeadPlayers.Add(zdoID.userID); ValheimEventHandler.OnPlayerDeath(GetPlayerInfo(__instance, zdoID)); } else if (DeadPlayers.Contains(zdoID.userID)) { DeadPlayers.Remove(zdoID.userID); } }
private static void Postfix(ref ZNet __instance) { if (!ZNet.m_isServer) { ZLog.Log("-------------------- SENDING VPLUGCONFIGSYNC REQUEST"); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "VPlusConfigSync", new object[] { new ZPackage() }); } }
private static void ZNet_OnNewConnection(ZNet __instance, ZNetPeer peer) { // clear the previous connection, if existing LastServerVersion = null; // Register our RPC very early peer.m_rpc.Register <ZPackage>(nameof(RPC_Jotunn_ReceiveVersionData), RPC_Jotunn_ReceiveVersionData); }
public static void PreventDisablePublicPosition(ZNet instance) { if (Configuration.Current.MapServer.IsEnabled && Configuration.Current.MapServer.preventPlayerFromTurningOffPublicPosition ) //isn't there a limit to identifiers in c#? { instance.m_publicReferencePosition = true; } }
public static void EnablePublicPosition(ZNet instance) { if (Configuration.Current.MapServer.IsEnabled && Configuration.Current.MapServer.playerPositionPublicOnJoin) { // Set player position visibility to public by default on server join instance.m_publicReferencePosition = true; } }
public static void RequestConfigSync(ZNet instance) { if (ZNet.instance.IsClientInstance()) { Logger.LogInfo("Sending config sync request to server"); ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), nameof(ConfigSync.RPC_ConfigSync), new ZPackage()); } }
public static void Postfix(ZNet __instance, ZNetPeer peer) { if (VACPlugin.posMap.ContainsKey(peer)) { return; } VACPlugin.posMap.Add(peer, Vector3.zero); }
private static void Postfix(ZNet __instance) { _instance = __instance; var l = BepInEx.Logging.Logger.CreateLogSource("ServerSideMap"); l.LogInfo("ZNet awake"); Store.ServerPinShare = false; }
private static void ZNet_SaveWorld(ref ZNet __instance) { if (isServer()) { // if (__instance.IsServer()) LaddersHandler.saveSkillLadder(); } }
private static bool Prefix(ZNet __instance, int error) { if (error == 7) { return(SmartBepInMods.Tools.Patching.Constants.CONST.SKIP); } return(SmartBepInMods.Tools.Patching.Constants.CONST.NOSKIP); }
protected override void Init() { InitServer(); net = new ZNet(server); AddSheduleCall(0.1f, net.UpdateOutMsg, 0.05f); }
public static void Write(ZNet.CMessage msg, CUserClass[] b) { Int32 data = b.Count(); Write(msg, data); for (Int32 i = 0; i < data; i++) { Write(msg, b[i]); } }
public bool request_out_room(ZNet.RemoteID remote, ZNet.CPackOption pkOption ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.request_out_room; Msg.WriteStart( msgID, pkOption, 0, true ); return PacketSend( remote, pkOption, Msg ); }
public bool request_move_to_server(ZNet.RemoteID remote, ZNet.CPackOption pkOption, int server_type ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.request_move_to_server; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, server_type ); return PacketSend( remote, pkOption, Msg ); }
public bool reponse_Udp(ZNet.RemoteID remote, ZNet.CPackOption pkOption, string msg ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.reponse_Udp; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, msg ); return PacketSend( remote, pkOption, Msg ); }
public bool request_join_room(ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.request_join_room; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, roomID ); return PacketSend( remote, pkOption, Msg ); }
public bool request_go_lobby(ZNet.RemoteID remote, ZNet.CPackOption pkOption, string lobbyname ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.request_go_lobby; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, lobbyname ); return PacketSend( remote, pkOption, Msg ); }
public bool GroupTestCommand(ZNet.RemoteID remote, ZNet.CPackOption pkOption, string cmd ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.GroupTestCommand; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, cmd ); return PacketSend( remote, pkOption, Msg ); }
public static void Write(ZNet.CMessage msg, Dictionary<ZNet.RemoteID, ZNet.MasterInfo> b) { Int32 data = b.Count; Write(msg, data); foreach (KeyValuePair<ZNet.RemoteID, ZNet.MasterInfo> obj in b) { Write(msg, obj.Key); Write(msg, obj.Value); } }
public static void Write(ZNet.CMessage msg, Dictionary<Int32, Int32> p) { Int32 data = p.Count; msg.Write(data); foreach (KeyValuePair<Int32, Int32> obj in p) { msg.Write(obj.Key); msg.Write(obj.Value); } }
public static void Read(ZNet.CMessage msg, out CUserClass[] b) { Int32 data; Read(msg, out data); b = new CUserClass[data]; for (Int32 i = 0; i < data; i++) { Read(msg, out b[i]); } }
public bool notify_lobby_list(ZNet.RemoteID remote, ZNet.CPackOption pkOption, Dictionary<ZNet.RemoteID,ZNet.MasterInfo> lobby_list ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.notify_lobby_list; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, lobby_list ); return PacketSend( remote, pkOption, Msg ); }
public bool reponse_move_to_server(ZNet.RemoteID remote, ZNet.CPackOption pkOption, bool result, ZNet.NetAddress addr ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.reponse_move_to_server; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, result ); RemoteClass.Marshaler.Write( Msg, addr ); return PacketSend( remote, pkOption, Msg ); }
public bool reponse_message(ZNet.RemoteID remote, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary<Int32,Int32> dic_test, string msg ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.reponse_message; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, testClass ); RemoteClass.Marshaler.Write( Msg, dic_test ); RemoteClass.Marshaler.Write( Msg, msg ); return PacketSend( remote, pkOption, Msg ); }
public override bool ProcessMsg(ZNet.CRecvedMsg rm) { ZNet.RemoteID remote = rm.remote; if( remote == ZNet.RemoteID.Remote_None ) { //err } ZNet.CPackOption pkOption = rm.pkop; ZNet.CMessage __msg = rm.msg; ZNet.PacketType PkID = rm.pkID; if( PkID < ZNet.PacketType.PacketType_User ) return true; switch( PkID ) { case Common.request_message: { RemoteClass.CUserClass testClass; RemoteClass.Marshaler.Read(__msg, out testClass); Dictionary<Int32,Int32> dic_test; RemoteClass.Marshaler.Read(__msg, out dic_test); string msg; RemoteClass.Marshaler.Read(__msg, out msg); bool bRet = request_message( remote, pkOption, testClass, dic_test, msg ); if( bRet==false ) NeedImplement("request_message"); } break; case Common.reponse_message: { RemoteClass.CUserClass testClass; RemoteClass.Marshaler.Read(__msg, out testClass); Dictionary<Int32,Int32> dic_test; RemoteClass.Marshaler.Read(__msg, out dic_test); string msg; RemoteClass.Marshaler.Read(__msg, out msg); bool bRet = reponse_message( remote, pkOption, testClass, dic_test, msg ); if( bRet==false ) NeedImplement("reponse_message"); } break; default: goto __fail; } return true; __fail: { //err return false; } }
public static void Read(ZNet.CMessage msg, out Dictionary<Int32, Int32> p) { Int32 data; msg.Read(out data); p = new Dictionary<Int32, Int32>(); for (Int32 i = 0; i < data; i++) { int _key; int _value; msg.Read(out _key); msg.Read(out _value); p.Add(_key, _value); } }
public static void Read(ZNet.CMessage msg, out Dictionary<ZNet.RemoteID, ZNet.MasterInfo> b) { Int32 data; Read(msg, out data); b = new Dictionary<ZNet.RemoteID, ZNet.MasterInfo>(); for (Int32 i = 0; i < data; i++) { ZNet.RemoteID _key; ZNet.MasterInfo _value; Read(msg, out _key); Read(msg, out _value); b.Add(_key, _value); } }
public bool room_lobby_makeroom(ZNet.RemoteID remote, ZNet.CPackOption pkOption, Guid roomID, string name, int number, ZNet.RemoteID remote_svr, ZNet.RemoteID remote_lobby, Guid userID ) { ZNet.CMessage Msg = new ZNet.CMessage(); ZNet.PacketType msgID = (ZNet.PacketType)Common.room_lobby_makeroom; Msg.WriteStart( msgID, pkOption, 0, true ); RemoteClass.Marshaler.Write( Msg, roomID ); RemoteClass.Marshaler.Write( Msg, name ); RemoteClass.Marshaler.Write( Msg, number ); RemoteClass.Marshaler.Write( Msg, remote_svr ); RemoteClass.Marshaler.Write( Msg, remote_lobby ); RemoteClass.Marshaler.Write( Msg, userID ); return PacketSend( remote, pkOption, Msg ); }
public static void Write(ZNet.CMessage msg, CUserClass b) { Write(msg, b.map_test); msg.Write(b.str_test); msg.Write(b.int_test); }
static public void ServerMoveParam1(MoveParam param, out ZNet.ArrByte buffer) { ZNet.CMessage msg = new ZNet.CMessage(); msg.Write((int)param.moveTo); msg.Write((int)param.roomJoin); msg.Write(param.room_id); msg.Write(param.lobby_remote); buffer = msg.m_array; }
static void DisplayStatus(ZNet.CoreServerNet svr) { ZNet.ServerState status; svr.GetCurrentState(out status); // 기본 정보 Console.WriteLine(string.Format( "[NetInfo] Connect/Join {0}({1})/{2} Connect(Server) {3}/{4} Accpet/Max {5}/{6}", // 실제 연결된 client status.m_CurrentClient, // 연결복구 처리과정인 client status.m_RecoveryCount, // 서버에 입장완료상태의 client status.m_JoinedClient, // 서버간 direct p2p 연결된 server status.m_ServerP2PCount, // 서버간 direct p2p 연결 모니터링중인 server(서버간 연결 자동복구를 위한 모니터링) status.m_ServerP2PConCount, // 이 서버에 추가 연결 가능한 숫자 status.m_nIoAccept, // 이 서버에 최대 연결 가능한 숫자 status.m_MaxAccept )); // 엔진 내부에서 작업중인 IO 관련 상태 정보 Console.WriteLine(string.Format( "[IO Info] Close {0} Event {1} Recv {2} Send {3}", // current io close status.m_nIoClose, // current io event status.m_nIoEvent, // current io recv socket status.m_nIoRecv, // current io send socket status.m_nIoSend )); // 엔진 메모리 관련 사용 정보 Console.WriteLine(string.Format( "[MemInfo] Alloc/Instant[{0}/{1}], test[{2}], EngineVersion[{3}.{4:0000}] ", // 미리 할당된 IO 메모리 status.m_nAlloc, // 즉석 할당된 IO 메모리 status.m_nAllocInstant, // test data status.m_test_data, // Core버전 svr.GetCoreVersion() / 10000, svr.GetCoreVersion() % 10000 )); // 스레드 정보 string strThr = "[ThreadInfo] ("; int MaxDisplayThreadCount = status.m_arrThread.Count(); if (MaxDisplayThreadCount > 8) // 화면이 복잡하니까 그냥 최대 8개까지만 표시 { strThr += MaxDisplayThreadCount; strThr += ") : "; MaxDisplayThreadCount = 8; } else { strThr += MaxDisplayThreadCount; strThr += ") : "; } for (int i = 0; i < MaxDisplayThreadCount; i++) { strThr += "["; strThr += status.m_arrThread[i].m_ThreadID; // 스레드ID strThr += "/"; strThr += status.m_arrThread[i].m_CountQueue; // 처리 대기중인 작업 strThr += "/"; strThr += status.m_arrThread[i].m_CountWorked; // 처리된 작업(누적) strThr += "] "; } Console.WriteLine(strThr); }
// 서버이동시 동기화할 유저 데이터 구성 static public void ServerMoveStart(CasualCommonSvr.CUser rc, out ZNet.ArrByte buffer) { ZNet.CMessage msg = new ZNet.CMessage(); msg.Write(rc.data.userID); msg.Write(rc.data.info); msg.Write(rc.data.temp); buffer = msg.m_array; }
static public void ServerMoveParam2(ZNet.ArrByte buffer, out MoveParam param) { param = new MoveParam(); ZNet.CMessage msg = new ZNet.CMessage(); msg.m_array = buffer; int _moveTo; int _roomJoin; msg.Read(out _moveTo); msg.Read(out _roomJoin); msg.Read(out param.room_id); msg.Read(out param.lobby_remote); param.moveTo = (MoveParam.ParamMove)_moveTo; param.roomJoin = (MoveParam.ParamRoom)_roomJoin; }
public bool reponse_message(ZNet.RemoteID[] remotes, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary<Int32,Int32> dic_test, string msg ) { foreach(var obj in remotes) reponse_message(obj, pkOption, testClass, dic_test, msg ); return true; }
// 서버이동 완료시 동기화할 유저 데이터 복구 static public void ServerMoveComplete(ZNet.ArrByte buffer, out CasualCommonSvr.CUser data) { CasualCommonSvr.CUser rc = new CasualCommonSvr.CUser(); ZNet.CMessage msg = new ZNet.CMessage(); msg.m_array = buffer; msg.Read(out rc.data.userID); msg.Read(out rc.data.info); msg.Read(out rc.data.temp); data = rc; }
public override bool ProcessMsg(ZNet.CRecvedMsg rm) { ZNet.RemoteID remote = rm.remote; if( remote == ZNet.RemoteID.Remote_None ) { //err } ZNet.CPackOption pkOption = rm.pkop; ZNet.CMessage __msg = rm.msg; ZNet.PacketType PkID = rm.pkID; if( PkID < ZNet.PacketType.PacketType_User ) return true; switch( PkID ) { case Common.request_lobby_list: { bool bRet = request_lobby_list( remote, pkOption ); if( bRet==false ) NeedImplement("request_lobby_list"); } break; case Common.notify_lobby_list: { Dictionary<ZNet.RemoteID,ZNet.MasterInfo> lobby_list; RemoteClass.Marshaler.Read(__msg, out lobby_list); bool bRet = notify_lobby_list( remote, pkOption, lobby_list ); if( bRet==false ) NeedImplement("notify_lobby_list"); } break; case Common.Chat: { string msg; RemoteClass.Marshaler.Read(__msg, out msg); bool bRet = Chat( remote, pkOption, msg ); if( bRet==false ) NeedImplement("Chat"); } break; case Common.request_go_lobby: { string lobbyname; RemoteClass.Marshaler.Read(__msg, out lobbyname); bool bRet = request_go_lobby( remote, pkOption, lobbyname ); if( bRet==false ) NeedImplement("request_go_lobby"); } break; case Common.request_make_room: { string name; RemoteClass.Marshaler.Read(__msg, out name); bool bRet = request_make_room( remote, pkOption, name ); if( bRet==false ) NeedImplement("request_make_room"); } break; case Common.request_join_room: { Guid roomID; RemoteClass.Marshaler.Read(__msg, out roomID); bool bRet = request_join_room( remote, pkOption, roomID ); if( bRet==false ) NeedImplement("request_join_room"); } break; case Common.request_out_room: { bool bRet = request_out_room( remote, pkOption ); if( bRet==false ) NeedImplement("request_out_room"); } break; case Common.room_lobby_makeroom: { Guid roomID; RemoteClass.Marshaler.Read(__msg, out roomID); string name; RemoteClass.Marshaler.Read(__msg, out name); int number; RemoteClass.Marshaler.Read(__msg, out number); ZNet.RemoteID remote_svr; RemoteClass.Marshaler.Read(__msg, out remote_svr); ZNet.RemoteID remote_lobby; RemoteClass.Marshaler.Read(__msg, out remote_lobby); Guid userID; RemoteClass.Marshaler.Read(__msg, out userID); bool bRet = room_lobby_makeroom( remote, pkOption, roomID, name, number, remote_svr, remote_lobby, userID ); if( bRet==false ) NeedImplement("room_lobby_makeroom"); } break; case Common.room_lobby_joinroom: { Guid roomID; RemoteClass.Marshaler.Read(__msg, out roomID); Guid userID; RemoteClass.Marshaler.Read(__msg, out userID); bool bRet = room_lobby_joinroom( remote, pkOption, roomID, userID ); if( bRet==false ) NeedImplement("room_lobby_joinroom"); } break; case Common.room_lobby_outroom: { Guid roomID; RemoteClass.Marshaler.Read(__msg, out roomID); Guid userID; RemoteClass.Marshaler.Read(__msg, out userID); bool bRet = room_lobby_outroom( remote, pkOption, roomID, userID ); if( bRet==false ) NeedImplement("room_lobby_outroom"); } break; default: goto __fail; } return true; __fail: { //err return false; } }
public override bool ProcessMsg(ZNet.CRecvedMsg rm) { ZNet.RemoteID remote = rm.remote; if( remote == ZNet.RemoteID.Remote_None ) { //err } ZNet.CPackOption pkOption = rm.pkop; ZNet.CMessage __msg = rm.msg; ZNet.PacketType PkID = rm.pkID; if( PkID < ZNet.PacketType.PacketType_User ) return true; switch( PkID ) { case Common.request_message: { string msg; RemoteClass.Marshaler.Read(__msg, out msg); bool bRet = request_message( remote, pkOption, msg ); if( bRet==false ) NeedImplement("request_message"); } break; case Common.reponse_message: { string msg; RemoteClass.Marshaler.Read(__msg, out msg); bool bRet = reponse_message( remote, pkOption, msg ); if( bRet==false ) NeedImplement("reponse_message"); } break; case Common.request_move_to_server: { int server_type; RemoteClass.Marshaler.Read(__msg, out server_type); bool bRet = request_move_to_server( remote, pkOption, server_type ); if( bRet==false ) NeedImplement("request_move_to_server"); } break; case Common.reponse_move_to_server: { bool result; RemoteClass.Marshaler.Read(__msg, out result); ZNet.NetAddress addr; RemoteClass.Marshaler.Read(__msg, out addr); bool bRet = reponse_move_to_server( remote, pkOption, result, addr ); if( bRet==false ) NeedImplement("reponse_move_to_server"); } break; default: goto __fail; } return true; __fail: { //err return false; } }