本文整理汇总了C#中SocketClient类的典型用法代码示例。如果您正苦于以下问题:C# SocketClient类的具体用法?C# SocketClient怎么用?C# SocketClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketClient类属于命名空间,在下文中一共展示了SocketClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
internal void Initialize(SocketClient client, TcpClient tcpClient)
{
this.client = client;
this.tcpClient = tcpClient;
this.onInitialize ();
}
示例2: Handel
public static void Handel(SocketClient client, ForgotPasswordRequest request)
{
var reply = new LoginResponse();
try
{
var user = AccountRepository.GetAccount(null, request.Email);
if (user != null)
{
if (user.Locked)
reply.ResponseType = LoginResponseType.AccountLocked;
else if (user.Verified)
{
user.Locked = true;
user.Verified = false;
user.Verificationcode = Guid.NewGuid().ToString();
reply.AccountId = user.Accountid;
reply.ResponseType = LoginResponseType.ResetSent;
EmailSender.SendRestEmail(user);
BaseRepository.Update(user);
}
else
reply.ResponseType = LoginResponseType.AccountNotVerified;
}
else
reply.ResponseType = LoginResponseType.ResetInvalid;
}
catch (Exception e)
{
reply.ResponseType = LoginResponseType.DatabaseError;
Logger.Error(e.Message);
}
client.Send(reply);
}
示例3: ChannelSelect
public static void ChannelSelect(byte[] packet, SocketClient sockstate)
{
CMSG_CHANNEL_SELECT cpkt = (CMSG_CHANNEL_SELECT)packet;
String SqrName = cpkt.SqrName;
lock (Program.SquareList)
{
for (int i = 0; i < Program.SquareList.Count; ++i)
{
if (Program.SquareList[i].Name == SqrName)
{
SMSG_CHANNEL_SELECT spkt = new SMSG_CHANNEL_SELECT(Program.SquareList[i], sockstate.SelectedChar);
SMSG_SEND_SESSION sessionPkt = new SMSG_SEND_SESSION(sockstate.SelectedChar);
try
{
// notify world
Program.SquareList[i].Socket.Client.Socket.Send(sessionPkt.Stream);
}
catch(Exception)
{
Logger.Log(Logger.LogLevel.Access, "World Server", "Server {0} not responding", Program.SquareList[i].Name);
Program.SquareList.RemoveAt(i);
}
// notify client
sockstate.Client.PacketQueue.Enqueue(spkt.Stream);
break;
}
}
}
}
示例4: Login
public static void Login(byte[] packet, SocketClient sockstate)
{
String Username;
String Password;
CMSG_ACCOUNT_LOGIN cpkt = (CMSG_ACCOUNT_LOGIN)packet;
Username = cpkt.Username;
Password = cpkt.Password;
Regex countPattern = new Regex("NHN_P_LOGIN=(.+);");
Match m1 = countPattern.Match(Password);
Password = m1.Groups[1].ToString();
// authenticate
SMSG_ACCOUNT_LOGIN accPkt = Database.Login(Username, Password, sockstate);
sockstate.Account.Username = Username;
sockstate.Client.PacketQueue.Enqueue(accPkt.Stream);
if (accPkt.LoginSuccess == true)
{
Logger.Log(Logger.LogLevel.Access, "Authentication", "Login accepted for user : {0} ", sockstate.Account.Username);
// send login options
SMSG_ACCOUNT_OPTIONS optionsPkt = new SMSG_ACCOUNT_OPTIONS();
optionsPkt.CharSlot = sockstate.Account.Options;
optionsPkt.CharUnlock = sockstate.Account.Options;
sockstate.Client.PacketQueue.Enqueue(optionsPkt.Stream);
// send character list
List<Structures.Mobile> Characters = Database.CharacterList(sockstate.Account.AID);
sockstate.Account.Characters = Characters;
SMSG_CHARACTER_LIST charlistPkt = new SMSG_CHARACTER_LIST(Characters);
sockstate.Client.PacketQueue.Enqueue(charlistPkt.Stream);
}
}
示例5: SentPacket
/// <summary>
/// Called when the packet is sent.
/// </summary>
/// <param name="p">The packet that was sent.</param>
public void SentPacket(Packet p, SocketClient client)
{
lock (syncSentPackets)
{
sentPackets.AddLast(new PacketSenderPair(p, client));
}
}
示例6: CharacterSelect
public static void CharacterSelect(byte[] packet, SocketClient sockstate)
{
String Name;
int CID = 0;
bool loginsuccess = true;
CMSG_CHARACTER_SELECT cpkt = (CMSG_CHARACTER_SELECT)packet;
Name = cpkt.Name;
foreach(Mobile character in sockstate.Account.Characters)
{
if (character.Name == Name)
{
CID = character.CID;
loginsuccess = true;
}
}
if (loginsuccess == true)
{
SMSG_CHARACTER_SELECT spkt = new SMSG_CHARACTER_SELECT(Name);
sockstate.Client.PacketQueue.Enqueue(spkt.Stream);
SMSG_CHANNEL_SLIME slimePkt = new SMSG_CHANNEL_SLIME();
sockstate.Client.PacketQueue.Enqueue(slimePkt.Stream);
sockstate.SelectedChar = CID;
}
else
{
Logger.Log(Logger.LogLevel.Error, "Hack Detection", "Account: {0} - Invalid Select Character Name: {1}", sockstate.Account.Username, Name);
sockstate.Disconnect();
}
}
示例7: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
SocketClient client = new SocketClient();
string resposta;
client.Connect("10.20.2.124", 6654);
client.Send("nomejogador/" + txtblock1.Text + "/" + txtblock2.Text);
resposta = client.Receive();
/*if (resposta.StartsWith("<ERRO>"))
{
MessageBox.Show(resposta);
}*/
if (resposta == "naocadastrado")
{
MessageBox.Show("Cliente não cadastrado ou senha inválida!");
}
else if (resposta == "naook")
{
MessageBox.Show("Cliente já está logado no sistema!");
}
else
{
NavigationService.Navigate(new Uri("/Menu.xaml", UriKind.RelativeOrAbsolute));
}
}
示例8: IsConnectedTest
public void IsConnectedTest()
{
SocketClient target = new SocketClient(); // TODO: 初始化为适当的值
bool actual;
actual = target.IsConnected;
Assert.Inconclusive( "验证此测试方法的正确性。" );
}
示例9: ConnectHandleManagerTest
public void ConnectHandleManagerTest()
{
SocketClient target = new SocketClient(); // TODO: 初始化为适当的值
ConnectHandleManager actual;
actual = target.ConnectHandleManager;
Assert.Inconclusive( "验证此测试方法的正确性。" );
}
示例10: ChannelPrevious
public static void ChannelPrevious(byte[] packet, SocketClient sockstate)
{
List<Structures.Mobile> Characters = Database.CharacterList(sockstate.Account.AID);
sockstate.Account.Characters = Characters;
SMSG_CHARACTER_LIST charlistPkt = new SMSG_CHARACTER_LIST(Characters);
sockstate.Client.PacketQueue.Enqueue(charlistPkt.Stream);
}
示例11: Handle
public static void Handle(SocketClient client, LoginResponse response)
{
if (response.ResponseType == LoginResponseType.AccountNotVerified)
EmailSender.SendWelcomeEmail(AccountRepository.GetAccount(response.AccountId));
if(response.ResponseType == LoginResponseType.AccountInUse)
Program.OnlineAccounts[response.AccountId].Disconnect();
}
示例12: Start
/* Unity Lifecyle */
void Start()
{
socketClient = new SocketClient("192.168.1.9", 1234, socketReadCallback);
if(SOCKET_ACTIVE) {
socketClient.connect();
}
}
示例13: SocketManager
static SocketManager()
{
//初始化数据包缓冲区,并设置了最大数据包尽可能的大
BuffListManger = new ZYNetRingBufferPool(400000);
client=new SocketClient();
client.DataOn += new DataOn(client_DataOn);
client.Disconnection += new ExceptionDisconnection(client_Disconnection);
}
示例14: SocketManager
static SocketManager()
{
Stream = new ZYNetBufferReadStreamV2(40960);
client = new SocketClient();
client.BinaryInput += new ClientBinaryInputHandler(client_BinaryInput);
client.ErrorLogOut += new ErrorLogOutHandler(client_ErrorLogOut);
client.MessageInput += new ClientMessageInputHandler(client_MessageInput);
}
示例15: u3dclient
public u3dclient()
{
register_function();
socket_client = new SocketClient(1048576, 1048576, 131072, null, new MessageHandler(MessageClient),
new CloseHandler(CloseClient), new ErrorHandler(ErrorClient), new ConnectHandler(on_connect));
}