mirror of
https://e.coding.net/circlecloud/SixiBroadcast.git
synced 2024-11-22 11:48:47 +00:00
客户端添加开机自动启 服务端添加指令系统...
This commit is contained in:
parent
e3a249fe54
commit
11bc60af26
@ -9,6 +9,7 @@ using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using UDPClient.Properties;
|
||||
|
||||
namespace UDPClient
|
||||
@ -30,6 +31,12 @@ namespace UDPClient
|
||||
|
||||
private void Frm_Client_Load(object sender, EventArgs e)
|
||||
{
|
||||
//开机自启动添加
|
||||
string path = Application.ExecutablePath;
|
||||
RegistryKey rk = Registry.LocalMachine.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
|
||||
rk.SetValue("SixiBroadcast", path);
|
||||
rk.Close();
|
||||
//初始化数据
|
||||
client = new UdpClient(new IPEndPoint(IPAddress.Any, 25333));
|
||||
serverendpoint = new IPEndPoint(IPAddress.Loopback, 25433);
|
||||
//启动客户端监听
|
||||
|
@ -20,11 +20,36 @@ namespace UDPServer
|
||||
//启动客户端监听
|
||||
Thread t = new Thread(new ThreadStart(ClientThread));
|
||||
t.Start();
|
||||
Console.WriteLine("请输入指令 或者 /help 查看帮助");
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("请输入需要公告的内容: ");
|
||||
string msg = Console.ReadLine();
|
||||
BroadcastMsg(msg);
|
||||
if (msg.StartsWith("/"))
|
||||
{
|
||||
switch (msg.Substring(1))
|
||||
{
|
||||
case "help":
|
||||
Console.WriteLine("/list 查看在线人员");
|
||||
Console.WriteLine("/broadcast 发送公告");
|
||||
break;
|
||||
case "list":
|
||||
Console.Write("当前在线(" + userinfo.Keys.Count + "): ");
|
||||
foreach (var item in userinfo)
|
||||
{
|
||||
Console.Write(item.Key + " ");
|
||||
}
|
||||
break;
|
||||
case "broadcast":
|
||||
if (msg.IndexOf(' ') > 0)
|
||||
BroadcastMsg(msg.Substring(msg.IndexOf(' ')));
|
||||
else
|
||||
Console.WriteLine("请输入公告内容!");
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("未知命令 请输入指令 或者 /help 查看帮助");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +92,7 @@ namespace UDPServer
|
||||
else
|
||||
{
|
||||
userinfo.Add(user, addr);
|
||||
Console.WriteLine("用户: " + user + " 登录服务器 IP: " + ip + " 端口: " + port);
|
||||
Console.WriteLine("用户: " + user + " 登录服务器 IP: " + ip + " 端口: " + port + "当前在线: " + userinfo.Keys.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user