Skip to content

EinarasGar/Event-driven-TCP-server-and-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event driven TCP server and client.

This repository contains TCP server and client core, which allows you to hook incoming packets, read them and respond to them instatnly.

How to use.

Server events:
  PacketRecieved 
  ClientConnected
  ClientDisonnected
  
Client events:
  Connected
  ServerPacketRecieved
  
Hook packets by using:
  HookPacket<PackeType>(CallBackFunction);
  
Create packets by making new instance of the packet:
  MessagePacket welcome = new MessagePacket();
  welcome.MessageType = MessagePacket.MessageTypes.Announcement;
  welcome.String = "Hello!";

Send packet by calling:
  Socket.send(Packet);
  
Expand packet list by adding new class in client or server folder making sure to inherit Packet
class and overriding PacketType, Read, Write 
  Example of expanding packet list:    
    class ExamplePacket : Packet
    {
        public int ExampleInt;
        public string ExampleString;

        public override PacketType Type
        { get { return PacketType.Example; } }

        public override void Read(PacketReader r)
        {
            ExampleInt = r.ReadInt32();
            ExampleString = r.ReadString();
        }

        public override void Write(PacketWriter w)
        {
            w.Write(ExampleInt);
            w.Write(ExampleString);
        }
    }
    

Example is included in PacketManager class in both projects.

About

TCP server and client which allows you to Hook specific packets, read them and send packets.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages