Skip to content

Add chat message classes#8

Open
aontas wants to merge 2 commits intodecaprime:mainfrom
aontas:networkChatMessage
Open

Add chat message classes#8
aontas wants to merge 2 commits intodecaprime:mainfrom
aontas:networkChatMessage

Conversation

@aontas
Copy link

@aontas aontas commented Jul 15, 2024

Adding in chat message alternate form of communication from server -> client.

First draft of adding it to Bloodstone (this form is currently untested, but the theory works). Am after any design changes or updates that I should make.

Tests would be useful to add.

Intended use:

SharedLibrary:

public struct DataPacket : VNetworkChatMessage
{
  string Data;
}

Server:

MessageUtils.OnClientConnectionEvent += (User user) => {
   // Client has connected! woo! now I can send them messages!
}

Client:

MessageUtils.RegisterType<DataPacket>((DataPacket message) => {
  // I have received this message. Need to cast it into appropriate type
});

// After client has sufficiently loaded to be able to receive messages
MessageUtils.InitialiseClient();

@aontas
Copy link
Author

aontas commented Jul 15, 2024

Feel free to request anything to move around or whatever. I not really sure where things are supposed to go (Should the ClientChat be in Hooks, or be in Network alongside SerialisationHooks?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant