jhg023 / SimpleNet

An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
MIT License
179 stars 19 forks source link

Custom / advanced event types. #15

Open MengelCode opened 4 years ago

MengelCode commented 4 years ago

We have the events connection, pre-disconnection and disconnection. Is it planned to give a user a way to add custom / more advanced types of events? I think of events such as:

*A message / data packet with specific content received, treat it elsewhere different from everything else.

jhg023 commented 4 years ago

@Mengel38 I'm open to adding events of other types.

However, I'm not a fan of an event that searches for data containing specific content. You can already achieve this by assigning opcodes to data that you send. When a specific opcode is received, special processing can be performed. I have an example of this in the README.

Currently, you also have the ability to track and update the last time a Client received any data from the Server by using an IdentityHashMap<Client, Instant>.

Regarding an event that would fire if a Client unexpectedly lost connection to the Server, I think is a reasonable request. I'll look into adding this soon.

Thanks for your suggestions!