Moved all client socket messages to document loaded function