Chat application in Grails

I am trying to create a chat application in grails. I have no idea how to do this, so could you point me in the right direction. The application does not have to be fantasy, I just want a simple application. Thanks

+4
source share
1 answer

The blog describes the basic principles:

http://programmingitch.blogspot.co.uk/2010/04/groovy-sockets-example.html

import java.net.ServerSocket def server = new ServerSocket(4444) while(true) { server.accept { socket -> println "processing new connection..." socket.withStreams { input, output -> def reader = input.newReader() def buffer = reader.readLine() println "server received: $buffer" now = new Date() output << "echo-response($now): " + buffer + "\n" } println "processing/thread complete." } } 

This gives you basic socket connections and I / O streams for the connected client. You will have to configure this to track multiple clients and send (send to all connected users) any messages from the server.

0
source

All Articles