本文整理汇总了C#中Server.Send方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Send方法的具体用法?C# Server.Send怎么用?C# Server.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server.Send方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleLogin
public static void HandleLogin(string username, Server server)
{
MainForm.mainForm.WriteLog(username + " connected!");
server.username = username; // Set the client username for the server
server.Send("Success|Verify"); // Send verification
}
示例2: PacketReceived
public static void PacketReceived(Server sender, Packet packet)
{
switch (packet.Opcode)
{
case 0x7FD3: // Login Request
{
string User = packet.ReadString(65);
string Pass = packet.ReadString(65);
LoginState State = AccountControl.GetLoginState(User, Pass);
switch (State)
{
case LoginState.Good:
{
Packet LoginResponse = new Packet(0x7FDA);
LoginResponse.WriteString(User.ToUpper( ), 31);
LoginResponse.WriteUInt(1); //Servers Count
LoginResponse.WriteString("abcdefghi", 11);
LoginResponse.WriteUShort(1);
LoginResponse.WriteString("Playing Server", 17);
LoginResponse.WriteString("", 23);
LoginResponse.WriteString("127.0.0.1", 16);
LoginResponse.WriteUShort(11305);
LoginResponse.WriteUShort(0);
LoginResponse.WriteByte((byte)ServerState.ConditionWell);
sender.Send(LoginResponse);
}
break;
case LoginState.NotID:
{
Packet LoginError = new Packet(0x7FD9);
LoginError.WriteUInt((uint)LoginState.NotID);
LoginError.WriteString("", 200);
LoginError.WriteString("", 200);
sender.Send(LoginError);
sender.Sock.Disconnect(true);
}
break;
case LoginState.WrongPass:
{
Packet LoginError = new Packet(0x7FD9);
LoginError.WriteUInt((uint)LoginState.WrongPass);
LoginError.WriteString("", 200);
LoginError.WriteString("", 200);
sender.Send(LoginError);
sender.Sock.Disconnect(true);
}
break;
}
}
break;
}
}
示例3: When_IOErrorThreshold_IsNot_Met_By_IOErrorInterval_NodeUnavailableException_Is_Thrown
public void When_IOErrorThreshold_IsNot_Met_By_IOErrorInterval_NodeUnavailableException_Is_Thrown()
{
var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json");
var config = JsonConvert.DeserializeObject<BucketConfig>(json);
var node = config.GetNodes().First();
var endPoint = UriExtensions.GetEndPoint(_address);
var configuration = new ClientConfiguration
{
IOErrorThreshold = 10,
IOErrorCheckInterval = 100
};
var connectionPool = new FakeConnectionPool();
var ioStrategy = new FakeIOStrategy(endPoint, connectionPool, false);
var server = new Server(ioStrategy,
node,
configuration,
config,
new FakeTranscoder());
Assert.IsFalse(server.IsDown);
var stopWatch = new Stopwatch();
stopWatch.Start();
for (int i = 0; i < 11; i++)
{
server.CheckOnline(true);
Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount);
Thread.Sleep(10);
}
// ReSharper disable once ThrowingSystemException
Assert.Throws<NodeUnavailableException>(() =>
{
var operation = new FakeOperation(new DefaultTranscoder());
server.Send(operation);
throw operation.Exception;
});
}
示例4: GetWorldPacketFor
protected override Server.Network.Packet GetWorldPacketFor(Server.Network.NetState state)
{
if ( state.Mobile != null && state.Mobile.AccessLevel >= AccessLevel.GameMaster )
state.Send( new GMItemPacket(this, true) );
return base.GetWorldPacketFor(state);
}