Ooops
A simple chat for socket.io
$ npm install
$ node index.js
And point your browser to http://localhost:3000
. Optionally, specify
a port by supplying the PORT
env variable.
Messages sent to server:
Register a user in the chat.
{
username: String,
avatar: String?
})
When the user start typing. No need to send when the user stops.
When a new message has to ben sent to the chat (limit to 500 characters)
message String
Messages sent to client:
When new users has joined/left the room
{
type: String<join|left>
user: User,
users: Array<User>
}
When you client got registered (after sending user register
)
When your client got registered you get a historical messages updates
{
messages: Array<Messages>
}
When a user start/stop typing
{
typing: Boolean,
user: User
}
When a new message is sent in the room
{
message: {
user: User,
text: String,
created: Date
},
messages: Array<Message>
}
When a command has been issued
{
command: String,
value: String
}
When an error has been thrown (see error codes)
{
code: Number,
message: String
}
100
: You are already connected with a username101
: Username is already taken102
: Username is invalid200
: The message is invalid201
: You are spamming too much, calm down!