📄 winaccept.cs
字号:
/*
<Aicaca Community Messenger Client>
Copyright (c) Aicaca.com, All rights reserved.
Writer : Byung-ku, Cho (Aicaca)
E-mail : aicaca@hanmail.net
Personal Homepage URL : http://www.aicaca.com
Last Updated Date : Feb. 27th, 2002
Programming Language : C#
Editor & Compiler : VisualStudio.NET
*/
using System;
using System.Threading;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.IO;
namespace TalkClient
{
public class WinAccept
{
private WinCom WC = new WinCom();
private WinClient xWinClient;
public Socket ServerSocket = null;
private string rootID;
private string localID;
public WinAccept(WinClient tWinClient, string tLocalID, string tRootID)
{
xWinClient = tWinClient;
this.localID = tLocalID;
this.rootID = tRootID;
}
public void CloseThis()
{
if (this.ServerSocket != null)
{
this.ServerSocket.Close();
xWinClient.pMainStatus = WC.lineStr3;
xWinClient.pProcessStatus = "";
}
}
private void OnReceive(Socket ClientSocket, string str)
{
str = str.Substring(0, str.Length-1);
string sort = WC.GetXML(str, "ms");
switch(sort)
{
case "ILOVEAICACAMSG":
xWinClient.AcceptILOVEAICACAMSG(ClientSocket, str);
break;
case "ILOVEAICACAFNO":
xWinClient.AcceptILOVEAICACAFNO(ClientSocket, str);
break;
case "ILOVEAICACAFAC":
xWinClient.AcceptILOVEAICACAFAC(ClientSocket, str);
break;
case "ILOVEAICACAFRE":
xWinClient.AcceptILOVEAICACAFRE(str);
break;
}
}
private void OnAccept(Socket ClientSocket)
{
string str = "";
string strOne = "";
char[] c = new char[1];
StreamReader SocketReader = null;
if (ClientSocket != null && ClientSocket.Connected)
{
NetworkStream stream = new NetworkStream(ClientSocket);
SocketReader = new StreamReader(stream);
}
while (SocketReader.Read(c,0,1) != 0)
{
strOne = new String(c);
str += strOne;
if (strOne == "\n")
{
this.OnReceive(ClientSocket, str);
break;
}
}
}
public void ServerProc()
{
string localSort = WC.GetXML(localID, "ls");
string localName = WC.GetXML(localID, "ln");
string localIP = WC.GetXML(localID, "li");
int localPort = Convert.ToInt32(WC.GetXML(localID, "lp"));
ServerSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
ServerSocket.Blocking = true;
while (true)
{
try
{
ServerSocket.Bind(new IPEndPoint(IPAddress.Any, localPort));
ServerSocket.Listen(-1);
xWinClient.pMainStatus = WC.lineStr2;
xWinClient.pProcessStatus = localName + ":" + localIP + ":" + localPort;
xWinClient.pLocalID = localID;
this.StartWinRoot();
break;
}
catch (Exception e)
{
localPort++;
localID = WC.MakeLocalID(localSort, localName, localIP, localPort.ToString());
}
}
while (ServerSocket != null)
{
Socket ClientSocket = ServerSocket.Accept();
lock(this)
{
if (ClientSocket != null)
{
this.OnAccept(ClientSocket);
}
}
}
if (ServerSocket != null)
{
this.ServerSocket.Close();
this.ServerSocket = null;
}
}
private void StartWinRoot()
{
WinRoot xWinRoot = new WinRoot(xWinClient, localID, rootID);
Thread RootThread = new Thread(new ThreadStart(xWinRoot.RootProc));
RootThread.Start();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -