⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winroot.cs

📁 一个即时通信 Messenger C#代码
💻 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 WinRoot
	{
		private WinCom WC = new WinCom();
		private WinClient xWinClient;

		public Socket RootSocket = null;

        private string rootID;
		private string localID;
		private bool eFlag = true;

		public WinRoot(WinClient tWinClient, string tLocalID, string tRootID)
		{
			xWinClient = tWinClient;
			this.localID = tLocalID;
			this.rootID = tRootID;
			xWinClient.pWinRoot = this;
		}

		public void CloseThis()
		{
			if (this.RootSocket != null)
			{
				this.eFlag = false;
				this.RootSocket.Close();
			}
		}

		private void OnReceive(string str)
		{
			str = str.Substring(0, str.Length-1);
			string sort = WC.GetXML(str, "ms");

			switch(sort)
			{
			    case "ILOVEAICACACFG":
					xWinClient.RootILOVEAICACACFG(str);
					break;
				case "ILOVEAICACACAS":
					xWinClient.RootILOVEAICACACAS(str);
					break;
				case "ILOVEAICACAMSG":
					xWinClient.RootILOVEAICACAMSG(str);
					break;
				case "ILOVEAICACAFNO":
					xWinClient.RootILOVEAICACAFNO(str);
					break;
				case "ILOVEAICACAFCA":
					xWinClient.RootILOVEAICACAFCA(str);
					break;
				case "ILOVEAICACAFAC":
					xWinClient.RootILOVEAICACAFAC(str);
					break;
				case "ILOVEAICACAFRE":
					xWinClient.RootILOVEAICACAFRE(str);
					break;
				case "ILOVEAICACAFIL":
					xWinClient.RootILOVEAICACAFIL(str);
					break;
				case "ILOVEAICACAERR":
					xWinClient.RootILOVEAICACAERR(str);
					break;
				case "ILOVEAICACAXLI":
					xWinClient.RootILOVEAICACAXLI(str);
					break;
				case "ILOVEAICACAXME":
					xWinClient.RootILOVEAICACAXME(str);
					break;
				case "ILOVEAICACAXFI":
					xWinClient.RootILOVEAICACAXFI(str);
					break;
				case "ILOVEAICACACHA":
					xWinClient.RootILOVEAICACACHA(str);
					break;
			}
		}

		public void RootProc()
		{
			string strOne = "";
			string str = "";
			char [] c = new char[1];
			string sendStr = WC.MakeXML("ms", "ILOVEAICACACAR") + localID + rootID;
			string rootIP = WC.GetXML(rootID, "ri");
			int rootPort = Convert.ToInt32(WC.GetXML(rootID, "rp"));

			RootSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
			IPAddress host_addr = Dns.GetHostByName(rootIP).AddressList[0];
			IPEndPoint ep = new IPEndPoint(host_addr, rootPort);

			try
			{
				RootSocket.Connect(ep);
			}
			catch (Exception e)
			{
				MessageBox.Show(WC.lineStr4);
				xWinClient.StopAll();
				return;
			}

			if (RootSocket != null && RootSocket.Connected)
			{
				NetworkStream stream = new NetworkStream(RootSocket);
				TextReader SocketReader = new StreamReader(stream);

				xWinClient.pRootSocket = RootSocket;
				xWinClient.SendRootMsg(sendStr);

				try
				{
					while (SocketReader.Read(c,0,1) != 0)
					{
						strOne = new String(c);
						str += strOne;
					
						if (strOne == "\n")
						{
							this.OnReceive(str);
							str = "";
						}	
					}
				}
				catch (Exception e)
				{
					if (eFlag == true)
					{
						MessageBox.Show(WC.lineStr5);
						xWinClient.ShutDown();
					}
				}

				if (RootSocket != null)
				{
					RootSocket.Close();
					RootSocket = null;
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -