I have a client server setup. When I send messages to the client from server or other way around I am using a kind of identifier on what type of message it is.

It is a chat server setup right now mainly for learning purposes. When a client sends a chat message to the server it looks like this:

m|message here

The server does a string split with "|" to find out what type of message and the data for the type of message.

Now the problem is "|" can be easily replicated by the client just by typing a message including that character causing the sent data to be incorrect when read by the server. I have made the client so it will remove all "|" in a user's message, but I don't want to do that.

My main question is what is the optimal way to send data to client/server that allows you to easily grab what type of data is being sent and the actual data for it. Rephrased a bit - say I have three different chat types in the client/server: whisper, say and yell. When the client chooses one and sends a message to the server how can I easily detect what type of chat type was sent and the actual sent message?