Hello, anyone can help me with small example, how can i send packets to the server?
string message = "Hey everyone, test test";
Packet send_all = new Packet(0x7025);
send_all.WriteUInt8(0x03);
send_all.WriteUInt8(0x00);
send_all.WriteAscii(message);
Agent.Send(send_all);
private static SimpleSilkroadClient client;
private static Thread thSessionUpdater;
static void Main(string[] args)
{
Console.Title = "SampleClient";
client = new SimpleSilkroadClient();
client.OnCommandReceived += Client_OnCommandReceived;
client.Connect("127.0.0.1", 39000);
thSessionUpdater = new Thread(ThreadedSessionUpdating);
thSessionUpdater.Start();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
private static void ThreadedSessionUpdating()
{
while (true)
{
if (client != null)
client.Update();
System.Threading.Thread.Sleep(1);
}
}
private static void Client_OnCommandReceived(Packet packet)
{
//PACKET HANDLING
if (packet.Opcode == 0x1234) //SAMPLE OPCODE
{
string message = packet.ReadAscii();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Message: {0}", message);
Console.ResetColor();
Packet sampleResponse = new Packet(0x1234);
sampleResponse.WriteAscii("Hello. It's nice being connected to you :)");
client.Send(sampleResponse);
}
}