// 各クライアント毎に処理するスレッド private void ClientStream(TcpClient client) { Debug.Log($"Accept client({((IPEndPoint)client.Client.RemoteEndPoint).Address}:{((IPEndPoint)client.Client.RemoteEndPoint).Port})と接続しました。"); client.LingerState = new LingerOption(true, 0); // 切断時は即切る NetIO.Setup(); // 受信処理作成 // 本来はクライアント毎に持つべきもの。 NetIO.Prefix = "server"; // 開始前コールバック NetIO.Begin(client); // 接続開始 // テスト送信 // HvNetIOTest.Send(networkIO); //接続されている限り読み続ける while (client.Connected && IsBegin) { Thread.Sleep(3000); HvNetIOTest.Send(NetIO); // 定期的にテスト送信 } Debug.Log($"server : out loop conedted:{client.Connected} _beginServer:{IsBegin} "); // 終了を通知 // HvNetIOCommand.SendEndCommand(NetIO); NetIO.Writer.Flush(); NetIO.CloseNetwork(); Thread.Sleep(50); NetIO.Dispose(); Thread.Sleep(100); }
/// <summary> /// After it 's time for finish counting. /// </summary> public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); GlobalInfo.coin = coin; GlobalInfo.cash = cash; GlobalInfo.myProfile.point = point; if (levelBonus > 0) { GlobalInfo.myProfile.level = level; GlobalInfo.myProfile.maxPoint = maxPoint; if (rankBonus > 0) { GlobalInfo.myProfile.rank = rank; GlobalInfo.rankName = rankName; GlobalInfo.crown = (crown > 0); } } if (recvScript != null) { recvScript.RecvGameEnd(this); } return(true); }
public void SendMsg(NetDataAnalysisBase analysis) { GameManager.instance.ShowLoading(true); NetIO nio0 = new NetIO(analysis.url); foreach (string prm in analysis.allparams) { nio0.AddParam(prm); } if (nio0.msg != "") { nio0.url += "?" + nio0.msg; nio0.msg = ""; nio0.url += "&userId=" + GlobalInfo.myProfile.user_id; } else { nio0.url += "?userId=" + GlobalInfo.myProfile.user_id; } if (!analysisDict.ContainsKey(nio0.url)) { analysisDict.Add(nio0.url, analysis); Debug.Log(nio0.url);// //NetMessage.Instance.Send(nio0); SendProtocol(nio0.url, analysis.url); } }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); if (recvScript != null) { recvScript.GetUserInfo(this); } return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); if (script != null) { script.ReceiveCupList(this); } return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); if (script != null) { script.OnSearchReceive(searchRes); } return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); if (script != null) { script.OnOnlineStatusReceive(this); } return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); for (int i = 0; i < winnerList.Length; i++) { TournamentChart.instance.GetComponent <PhotonView>().RPC("SetWinner", PhotonTargets.AllBuffered , winnerList[i].pos, winnerList[i].pos0); } return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); GlobalInfo.cash = value; if (CashUI.instance) { CashUI.instance.UpdateValue(); } return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); for (int i = 0; i < ballStatus.Length; i++) { TournamentChart.instance.GetComponent <PhotonView>().RPC("SetBalls", PhotonTargets.AllBuffered , ballStatus[i].pos, ballStatus[i].i, ballStatus[i].num); } return(true); }
public static void Broadcast(Cutscene cutscene) { if (Main.netMode != NetmodeID.MultiplayerClient) { throw new ModHelpersException("Not client"); } CutsceneStartProtocol protocol = cutscene.CreatePacketPayload(); NetIO.Broadcast(protocol); }
public static void Broadcast(Cutscene cutscene) { if (Main.netMode != NetmodeID.MultiplayerClient) { throw new ModHelpersException("Not client"); } var protocol = new CutsceneEndProtocol(cutscene); NetIO.Broadcast(protocol); }
public static void SendToClients(Cutscene cutscene, int ignoreWho) { if (Main.netMode != NetmodeID.Server) { throw new ModHelpersException("Not server"); } var protocol = new CutsceneEndProtocol(cutscene); NetIO.SendToClients( data: protocol, ignoreWho: ignoreWho ); }
public static void SendToClients(Cutscene cutscene, int ignoreWho) { if (Main.netMode != NetmodeID.Server) { throw new ModHelpersException("Not server"); } CutsceneStartProtocol protocol = cutscene.CreatePacketPayload(); NetIO.SendToClients( data: protocol, ignoreWho: ignoreWho ); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); if (type == 1) //coin { GlobalInfo.coin = value; } else { GlobalInfo.cash = value; } if (CashUI.instance) { CashUI.instance.UpdateValue(); } item.purchase_mode = PURCHASE_MODE.BOUGHT; if (tableName == "tablecolor") { recvScript.colorBuyBtn.SetActive(false); recvScript.colorUseBtn.SetActive(true); } else if (tableName == "tableframe") { recvScript.ShowTableSegment(id); } else if (tableName == "tablepattern") { recvScript.patternBuyBtn.SetActive(false); recvScript.patternUseBtn.SetActive(true); } else if (tableName == "data_cue") { cueScript.ShowCue(id); } else if (tableName == "data_avatar") { avatarScript.ShowAvatar(id); } return(true); }
protected void RecvMsg() { for (int i = protocolList.Count - 1; i >= 0; --i) { protocolList[i].Update(); if (protocolList[i].resultCode != ResultCodeType.None) { res = protocolList[i]; if (res.resultCode == ResultCodeType.Success) { nio = new NetIO(res.url, res.resultValue); if (analysisDict.ContainsKey(nio.url)) { NetDataAnalysisBase netAnalysis = analysisDict[nio.url]; analysisDict.Remove(nio.url); Debug.Log(netAnalysis.GetType().Name + nio.msg); netAnalysis.Analysis(nio); } } protocolList.RemoveAt(i); GameManager.instance.ShowLoading(false); } } }
void Start() { NetIO io = NetIO.Instance; }
public abstract bool Analysis(NetIO nio);
// Use this for initialization void Start() { NetIO net = NetIO.Instance; //启动连接服务器 (在登录界面显示时就应该是连接服务器) }
public static void Main(string[] args) { string title = "Start Source dedicated server ver " + (FileVersionInfo.GetVersionInfo((Assembly.GetExecutingAssembly()).Location)).ProductVersion + ": "; Console.Title = title; Console_ResetColor(); Console.Clear(); Console.ForegroundColor = ConsoleColor.Blue; Console.WriteLine("***************************************************"); Console.WriteLine(title); Console.WriteLine("***************************************************"); int argsLength = args.Length; if (argsLength < 6) { Console.WriteLine("Usage: srcdsStarter <Server_name> <path> <mod> <ip> <port> <cmd> [<rcon_password>] "); ScriptFinish(true); System.Environment.Exit(0); } //for (int i=0;i!=argsLength;i++) // { // Console.WriteLine("arg({0})={1}",i,args[i]); // } srcds_name = args[0]; srcds_folder = args[1]; srcds_mod = args[2]; srcds_ip = System.Net.IPAddress.Parse(args[3]); srcds_port = Int32.Parse(args[4]); srcds_cmd = args[5]; //srcds_rcon_password FolderIO.CheckFolderString(ref srcds_folder); Console.WriteLine("name= "+ srcds_name); Console.WriteLine("folder= "+ srcds_folder); Console.WriteLine("mod= " + srcds_mod); Console.WriteLine("ip= "+ srcds_ip); Console.WriteLine("port= "+ srcds_port); Console.WriteLine("command line= "+ srcds_cmd); // //Test that all ready to start // if (!Directory.Exists(srcds_folder)) //Folder with srcds exist { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERR: Folder {0} not found.", srcds_folder); Console_ResetColor(); ScriptFinish(true); System.Environment.Exit(4); } if (!File.Exists(srcds_folder + srcds_run)) //File srcds.exe exist { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERR: File {0} doesn't exist in folder {1} not found.", srcds_run, srcds_folder); Console_ResetColor(); ScriptFinish(true); System.Environment.Exit(4); } if (!Directory.Exists(srcds_folder + srcds_mod)) //Mod folder exist { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERR: Folder {0} not found in {1}.", srcds_mod, srcds_folder); Console_ResetColor(); ScriptFinish(true); System.Environment.Exit(4); } // // Check IP:PORT // IPEndPoint BusySocket = NetIO.BusyTCPSocket(srcds_port, srcds_ip); while (BusySocket != null) { ReadyToRun = false; Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("Socket TCP {1}:{0} are busy ", BusySocket.Port, BusySocket.Address); int PID = NetIO.GetPortProcessID(BusySocket.Port); if (PID != 0) { Console.Write("by PID {0} ", PID); string socket_process_name = Process.GetProcessById(PID).ProcessName; Console.WriteLine("of process {0}", socket_process_name); if (socket_process_name != "srcds") { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Socket process is not srcds. Starter will close."); ScriptFinish(true); System.Environment.Exit(5); } int ParentPID = (int)K64t.ProcessUtil.GetParentProcessID(PID); if (!K64t.ProcessUtil.IsProcessRunning(ParentPID)) { ParentPID = 0; } if (ParentPID != 0) { Console.Write("Socket process has parent PID {0}", ParentPID); socket_process_name = Process.GetProcessById((int)ParentPID).ProcessName; Console.Write(" process {0}.", socket_process_name); //Проверить что родительский процесс вообще запущен if (socket_process_name == "srcdsStarter") { Console.WriteLine("Try to kill old srcdsStarter."); Process.GetProcessById((int)ParentPID).Kill(); } } //Close srcds over RCON /* * Console.ForegroundColor=ConsoleColor.Cyan; * Console.WriteLine("Try to close srcds over rcon."); * SourceRcon.SourceRcon RCon = new SourceRcon.SourceRcon(); * RCon.Errors += new SourceRcon.StringOutput(ErrorOutput); * RCon.ServerOutput += new SourceRcon.StringOutput(ConsoleOutput); * try * { * RCon.Connect(new IPEndPoint(srcds_ip, srcds_port),srcds_rcon_password); * for (int i=0;i!=10;i++) * { * Thread.Sleep(1000); * if (RCon.Connected) break; * } * * } * catch (Exception e) * { * Console.WriteLine(e.Message.ToString()); * } * if (RCon.Connected) * { * Console.ForegroundColor=ConsoleColor.Green; * Console.WriteLine("Connected");Console_ResetColor(); * * try { * RCon.ServerCommand("quit"); * }catch (Exception e){Console.ForegroundColor=ConsoleColor.Red;Console.WriteLine(e.Message);} * Thread.Sleep(100); * } * else * { * Console.ForegroundColor=ConsoleColor.Red; * Console.WriteLine("ERR: No connection."); * Console_ResetColor(); * } * Thread.Sleep(1000); * RCon=null; */ //Trying to close srcds process Console.WriteLine("Closing srcds process with PID {0}...", PID); Process.GetProcessById((int)PID).Kill(); Thread.Sleep(1000); if (K64t.ProcessUtil.IsProcessRunning(PID)) { Console.WriteLine("ERR"); } else { Console.WriteLine("OK"); } } else { Console.WriteLine("by unknown process."); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Starter will close."); ScriptFinish(true); System.Environment.Exit(5); } Thread.Sleep(1000); BusySocket = NetIO.BusyTCPSocket(srcds_port, srcds_ip); } ReadyToRun = true; /*BusySocket= BusyUDPSocket(); * if (BusySocket!=null) * { * Console.ForegroundColor=ConsoleColor.Yellow; * Console.WriteLine("Socket UDP {1}:{0} are busy. Trying to close process",BusySocket.Port,BusySocket.Address); * ReadyToRun=false; * }*/ // // Run srcds.exe // Console.Title = title + " " + srcds_name + " " + DateTime.Now.ToString(); if (ReadyToRun) { Process srcds = new Process(); srcds.StartInfo.RedirectStandardOutput = true; srcds.StartInfo.RedirectStandardError = true; srcds.StartInfo.CreateNoWindow = true; srcds.StartInfo.WorkingDirectory = srcds_folder; srcds.StartInfo.FileName = srcds_folder + srcds_run; srcds.StartInfo.UseShellExecute = false; //https://msdn.microsoft.com/ru-ru/library/system.diagnostics.processstartinfo.workingdirectory(v=vs.110).aspx srcds.StartInfo.Arguments += " -game " + srcds_mod; srcds.StartInfo.Arguments += " +ip " + srcds_ip; srcds.StartInfo.Arguments += " -port " + srcds_port; srcds.StartInfo.Arguments += " +hostname " + srcds_name; //srcds.StartInfo.Arguments+=" -nocrashdialog -nomaster -console -insecure +sv_lan 1 "+srcds_cmd; srcds.StartInfo.Arguments += srcds_cmd; srcds.StartInfo.Arguments += " " + srds_default_command_line_params; srcds.StartInfo.UseShellExecute = false; #if (bbDEBUG) srcds.StartInfo.RedirectStandardOutput = true; #else srcds.StartInfo.RedirectStandardOutput = false; #endif while (true) { Console.ForegroundColor = ConsoleColor.White; Console.Write("{1} \nRun {0} ", srcds_run, DateTime.Now); Console_ResetColor(); Console.WriteLine(srcds.StartInfo.Arguments); try { srcds.Start(); } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(e.Message); Console_ResetColor(); } #if (bbDEBUG) string output = srcds.StandardOutput.ReadToEnd(); string err = srcds.StandardError.ReadToEnd(); Console.WriteLine(output); Console.WriteLine(err); #endif IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; ShowWindow(handle, 6); srcds.WaitForExit(); if (srcds.ExitCode > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ERRORLEVEL " + srcds.ExitCode); Console_ResetColor(); } } } ScriptFinish(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); TournamentChart.instance.GetComponent <PhotonView>().RPC("SetT_ID", PhotonTargets.AllBuffered, t_id + 1); return(true); }
public override bool Analysis(NetIO nio) { nio.ReadJsonValue(this); return(true); }
public static void SendToServer(CutsceneLibPlayer plrData) { var protocol = new PlayerDataNetData(plrData); NetIO.SendToServer(protocol); }
protected override void OnStart() { base.OnStart(); NetIO io = NetIO.Instance; }
public static void SendToClients(CutsceneLibPlayer plrData, int toWho, int ignoreWho) { var protocol = new PlayerDataNetData(plrData); NetIO.SendToClients(protocol, toWho, ignoreWho); }