func (s *Server) OpenWebsocketConnection(w http.ResponseWriter, r *http.Request) {
	out := make(chan *Message)
	in := make(chan *Message)
	events := make(chan *Event)
	conn, err := upgrader.Upgrade(w, r, nil)
	if err != nil {
		log.Println(err)
		return
	}

	// defer connection.Close()
	fmt.Printf("Opening new connection ...\n\n")
	socket := &Socket{server: s, connection: conn, messagesOut: out, messagesIn: in, events: events}

	go socket.handleMessagesOut() //Handle messages from server socket to client
	go socket.handleMessagesIn()  //Handle messages from client to server socket
	socket.listenToMessagesIn()

}
// OpenWebsocketConnection opens a new websocket connection
OpenWebsocketConnection opens a new websocket connection
// OpenWebsocketConnection opens a new websocket connection
func (s *Server) OpenWebsocketConnection(w http.ResponseWriter, r *http.Request) {
	out := make(chan *Message)
	in := make(chan *Message)
	events := make(chan *Event)
	conn, err := upgrader.Upgrade(w, r, nil)
	if err != nil {
		log.Println(err)
		return
	}
	fmt.Printf("Opening new connection ...\n\n")
	socket := &Socket{server: s, connection: conn, messagesOut: out, messagesIn: in, events: events}
	go socket.handleMessagesOut() 
	go socket.handleMessagesIn()  
	socket.listenToMessagesIn()
}
func ( s * Server ) OpenWebsocketConnection ( w http . ResponseWriter , r * http . Request ) { out := make ( chan * Message ) in := make ( chan * Message ) events := make ( chan * Event ) conn , err := upgrader . Upgrade ( w , r , nil ) if err != nil { log . Println ( err ) return } fmt . Printf ( " \n \n " ) socket := & Socket { server : s , connection : conn , messagesOut : out , messagesIn : in , events : events } go socket . handleMessagesOut ( ) go socket . handleMessagesIn ( ) socket . listenToMessagesIn ( ) }
OpenWebsocketConnection opens a new websocket connection
OpenWebsocketConnection opens a new websocket connection
// defer connection.Close() //Handle messages from server socket to client //Handle messages from client to server socket