websocket is a chatroom websocket server. Written in C++ using libwebsockets: https://libwebsockets.org/lws-api-doc-master/html/md_READMEs_README_8coding.html

unknown 9652c94623 Initial upload 11 maanden geleden
Debug.cpp 9652c94623 Initial upload 11 maanden geleden
Debug.h 9652c94623 Initial upload 11 maanden geleden
StackTrace.cpp 9652c94623 Initial upload 11 maanden geleden
StackTrace.h 9652c94623 Initial upload 11 maanden geleden
biglist.h 9652c94623 Initial upload 11 maanden geleden
chatclient.cpp 9652c94623 Initial upload 11 maanden geleden
chatclient.h 9652c94623 Initial upload 11 maanden geleden
chatcommand.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_addchatroom.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_addchatroom.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_adduser.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_adduser.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_getchatroomlist.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_getchatroomlist.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_getusers.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_getusers.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_getusersinchatroom.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_getusersinchatroom.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_joinchatroom.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_joinchatroom.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_joinsimplegame.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_joinsimplegame.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_leavechatroom.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_leavechatroom.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_leavesimplegame.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_leavesimplegame.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_login.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_login.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_logout.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_logout.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_nop.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_nop.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_removechatroom.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_removechatroom.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_removeuser.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_removeuser.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_send.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_send.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_sendto.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_sendto.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_sendtoall.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_sendtoall.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegamechat.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegamechat.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegamesetdata.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegamesetdata.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegameusergetdata.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegameusergetdata.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegameusers.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegameusers.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegameusersetdata.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_simplegameusersetdata.h 9652c94623 Initial upload 11 maanden geleden
chatcommand_startsimplegame.cpp 9652c94623 Initial upload 11 maanden geleden
chatcommand_startsimplegame.h 9652c94623 Initial upload 11 maanden geleden
chatroom.cpp 9652c94623 Initial upload 11 maanden geleden
chatroom.h 9652c94623 Initial upload 11 maanden geleden
concurrent_queue.h 9652c94623 Initial upload 11 maanden geleden
datablock.cpp 9652c94623 Initial upload 11 maanden geleden
datablock.h 9652c94623 Initial upload 11 maanden geleden
datastring.cpp 9652c94623 Initial upload 11 maanden geleden
datastring.h 9652c94623 Initial upload 11 maanden geleden
error_signals.cpp 9652c94623 Initial upload 11 maanden geleden
error_signals.h 9652c94623 Initial upload 11 maanden geleden
example.html 9652c94623 Initial upload 11 maanden geleden
idisposable.cpp 9652c94623 Initial upload 11 maanden geleden
idisposable.h 9652c94623 Initial upload 11 maanden geleden
main.cpp 9652c94623 Initial upload 11 maanden geleden
main.h 9652c94623 Initial upload 11 maanden geleden
makefile 9652c94623 Initial upload 11 maanden geleden
message.cpp 9652c94623 Initial upload 11 maanden geleden
message.h 9652c94623 Initial upload 11 maanden geleden
parameters.cpp 9652c94623 Initial upload 11 maanden geleden
parameters.h 9652c94623 Initial upload 11 maanden geleden
readme.txt 9652c94623 Initial upload 11 maanden geleden
save 9652c94623 Initial upload 11 maanden geleden
sha256.cpp 9652c94623 Initial upload 11 maanden geleden
sha256.h 9652c94623 Initial upload 11 maanden geleden
simplechatgame.cpp 9652c94623 Initial upload 11 maanden geleden
simplechatgame.h 9652c94623 Initial upload 11 maanden geleden
simplechatgameuser.cpp 9652c94623 Initial upload 11 maanden geleden
simplechatgameuser.h 9652c94623 Initial upload 11 maanden geleden
stringbuilder.cpp 9652c94623 Initial upload 11 maanden geleden
stringbuilder.h 9652c94623 Initial upload 11 maanden geleden
task.cpp 9652c94623 Initial upload 11 maanden geleden
task.h 9652c94623 Initial upload 11 maanden geleden
tasks.cpp 9652c94623 Initial upload 11 maanden geleden
tasks.h 9652c94623 Initial upload 11 maanden geleden
test.cpp 9652c94623 Initial upload 11 maanden geleden
test.h 9652c94623 Initial upload 11 maanden geleden
tictactoe.htm 9652c94623 Initial upload 11 maanden geleden
user.cpp 9652c94623 Initial upload 11 maanden geleden
user.h 9652c94623 Initial upload 11 maanden geleden
websocket.cpp 9652c94623 Initial upload 11 maanden geleden
websocket.h 9652c94623 Initial upload 11 maanden geleden

readme.txt

Read Me:

Q. Why do a chatroom in C++ instead of C#?
A. Because C# has a "stop the world" garbage collector.

Q. Is this application multithreaded?
A. Yes. There are two threads. One sending and receiving messages
from a queue when clients are available and one thread processing messages.
Because only one thread is processing messages, no locking is needed.

websocket is a chatroom websocket server.
Written in C++ using libwebsockets:
https://libwebsockets.org/lws-api-doc-master/html/md_READMEs_README_8coding.html

websocket Port ServerPassword
starts the websocket server listening to Port.
ServerPassword is the password to edit users/chatrooms.

websocket test classname
Runs the test for classname.

websocket test testnumber
testnumber can be from 1 to 5

websocket test all
Runs all the tests.

Clients connect and send commands to the server. The server sends commands back.
Commands consist of the command name then a ( then parameters then )
Numbers are sent comma delimited.
Examples: 3,12,16
Strings are sent with the length in base 10 then a comma then the text.
There's no comma after the text because the length is already known.
Examples: 4,test6,client
messageid is a unique number the client sends with each message.
The messageid if the server response will match the messageid of the client.
If a message comes from another client, that messageid won't match
because each client assigns its own message id.

Commands the client send to the server:
sendtoall(server_password,messageid,message)
Returns success(messageid) or error(message,messageid).
sends privatemessage(chatclientid,userid,username,message) to all users.
If user isn't logged in, userid = 0 and username is blank.
addchatroom(messageid,room_name,question,answer,answer_hashed,server_password)
Adds a chatroom.
Returns chatroomcreated(messageid,chatroomid,room_name) or error(message,messageid).
If server_password is not sent then everyone_can_join and delete_if_unused are true.
question and answer and answer_hashed can be blank.
getchatroomlist(messageid)
Returns a list of all chatrooms. The list is returned with the chatroomlist command.
adduser(messageid,userid,username,password,server_password)
The server_password is required. The idea is that
some other service connects and feeds this from a database.
login(messageid,username,password)
Logs in. Returns success or error messages.
TODO: This will connect to a database.
logout(messageid,disconnect)
Logs the connection out. If disconnect is not 0, then also disconnects.
Sends a success message if disconnect == 0.
Sends an error message if you're already logged out and disconnect == 0.
joinchatroom(messageid,chatroomid,leave_other_chatrooms,answerhashed,server_password)
Joins a chatroom. server_password is for secure chatrooms.
Answerhashed is required for chatrooms with question/answers.
server_password is required the server password was used when the chatroom was added.
If leave_other_chatrooms is not zero then any other chatrooms are left.
send(messageid,chatroomid,message)
Send a chat message to everybody in the chatroom.
leavechatroom(messageid,chatroomid)
Leaves a chatroom. Returns a userleftchatroom message or an error.
getusersinchatroom(messageid,chatroomid)
Returns the list of users/clients in the chatroom. usersinchatroom message.
removechatroom(messageid,chatroomid,server_password)
Removes a chatroom. Requires server password.
Sends a chatroomwasdeleted message to you and everybody in the chatroom.
sendto(messageid,chatclientid,userid,message)
Sends a message to a specific user or chatclientid.
Chatclientid and userid are optional, but you must send at least one.
Sends message to the user or error back to the caller. See msg below.
removeuser(messageid,userid,server_password)
Removes a user from ram. Server_password is required.
nop()
No operation. This is used by the client to keep the connection alive. No response.
getusers(messageid,status,server_password)
Gets the list of users in ram. Server_password is required.
If status == 1, only return users that are logged in.
If status == 2, only return users that are logged off.
If status == 3, return both users logged in and users logged off.
Returns a users message or an error.
Simple games are games where you just ask their name and don't have defined users/passwords.
One person starts a game and tells the gameid to the other person to join the game.
startsimplegame(messageid,gameid,username,gamedata)
Starts a simple chat game.
Returns a simplegamestarted message or an error if gameid is already used.
joinsimplegame(messageid,gameid,username,gamedata)
Joins a simple chat game. Appends gamedata to the game's gamedata.
Returns a simplegamejoined message to all players in the game or an error.
simplegamesetdata(messageid,gameid,offset,newgamedata)
Sets the gamedata in a game. Sends a simplegamedata message or an error. Offset is where to save newgamedata within gamedata. Use -1 to replace.
leavesimplegame(messageid,gameid,offset,newgamedata)
Leaves a simple game. Returns a simplegameleave message to all users in the game or an error. Offset is where to save newgamedata within gamedata. Use -1 to replace.
simplegamechat(messageid,gameid,username,message)
Sends a chat message to usename in a simple game. Sends a simplegamechat message to the user and a success message or an error message to the caller.
simplegameusers(messageid,gameid)
Returns the list of users in a game. Returns a simplegameusers message or an error message.
simplegameusersetdata(messageid,gameid,userdata)
Sets the data for a user in a game. Returns a success message or an error message. Also sends a simplegameuserdata message to all the other users telling them the data change.
simplegameusergetdata(messageid,gameid,username)
Gets the data for a user in a game. Returns a simplegameuserdata message or an error message. If username is left out, returns the user data for all users.

Commands the server sends to the client:
success(messageid)
The message was processed successfully.
error(message,messageid)
The message had an error.
error(message,messageid)
The message had such a bad error, the messageid wasn't parsed out. Messageid might be zero.
chatroomcreated(messageid,chatroomid,room_name,question,answer)
Some user created a chatroom.
chatroomwasdeleted(messageid,chatroomid);
A chatroom was just deleted.
chatroomlist(messageid,[chatroomid,room_name,info])
The list of chatrooms. [ ] is a array. No [ or ] is in the data.
info is a number:
bit 1 = Are you in this chatroom.
bit 2 = Can everybody join this chatroom. If not, then requires server_password to join.
bit 3 = Does this chatroom require a password. This would be an answer to a question.
bit 4 = Will this chatroom be deleted when everybody leaves.
userjoinedchatroom(messageid,chatroomid,chatclientid,userid,username)
The user joined a chatroom.
userleftchatroom(messageid,chatroomid,chatclientid,userid,username)
The user left the chat room.
yourchatclientid(chatclientid)
This is your chatclientid. Each time you connect, you get a different
chat client id.
chat(messageid,chatroomid,chatclientid,userid,message)
A message from somebody in the chatroom.
usersinchatroom(messageid,chatroomid,[chatclientid,userid,username])
List of users in a chatroom.
users(messageid,[userid,username,status])
List of users. status is 1 for logged in, 2 for logged out.
msg(messageid,chatclientid,userid,message)
A private message from the sendto command.
simplegamestarted(messageid,gameid)
A message that the game was started.
simplegamejoined(messageid,gameid,gamedata,user list)
A message that username joined a simple chat game.
simplegamedata(messageid,gameid,username,gamedata)
A message that username set the gamedata for simplegame.
simplegameleave(messageid,gameid,username,gamedata)
A message that username left the simple game.
simplegamechat(messageid,gameid,username,message)
A message from username in a simple chat game.
simplegameusers(messageid,gameid,userlist)
A message listing the users in a game. After each user is Up or Down to denote if the user is connected to the game still.
When a client disconnects, all the other users receive this message with messageid of zero.
simplegameuserdata(messageid,gameid,username,userdata)
A message listing the user data for a user in a game.