Skip to content

Commit

Permalink
updates for wschat version 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidhedayati committed Jul 4, 2015
1 parent 38c6297 commit 1486068
Show file tree
Hide file tree
Showing 49 changed files with 1,186 additions and 1,021 deletions.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ Chat rooms can be created in Config.groovy +/ DB once logged in using UI.

###### Dependency (Grails 2.X) :
```groovy
compile ":wschat:1.18"
compile ":wschat:1.19"
```

[codebase for grails 2.X](https://github.com/vahidhedayati/grails-wschat-plugin/tree/grails2)


###### Dependency (Grails 3.X) :
```groovy
compile "org.grails.plugins:wschat:3.0.1"
compile "org.grails.plugins:wschat:3.0.2"
```

[codebase for grails 3.X](https://github.com/vahidhedayati/grails-wschat-plugin/)
Expand Down Expand Up @@ -150,6 +150,51 @@ before running grails run-app



### Customised chat menus for your chat users:
[index.gsp](https://github.com/vahidhedayati/testwschat/tree/master/grails-app/views/test/index.gsp)
```gsp
<g:form action="index2">
<label>Chat username</label><g:textField name="username"/>
<label>Choose Chat room style</label><g:select name="chatType" from="${selectMap}" optionKey="key" optionValue="value" />
<g:submitButton name="submit" value="go" />
</g:form>
```

[Controller for index:](https://github.com/vahidhedayati/testwschat/blob/master/grails-app/controllers/testwschat/TestController.groovy)
```groovy
def index() {
Map selectMap = ['usermenu':'default (as per plugin)','webrtcav':'webrtc AV only options', 'webrtcscreen':'screen share options only',
'fileonly':'display file interaction only', 'webcam':'web cam only', 'none':'no AV options' ]
render view: 'index', model: [selectMap:selectMap]
}
```

[View for index2:](https://github.com/vahidhedayati/testwschat/blob/master/grails-app/views/test/index2.gsp)
```gsp
<chat:includeAllStyle
addLayouts="true"
jquery="true"
jqueryui="true"
bootstrap="true"
/>
<chat:connect
chatuser="${params.username}"
usermenujs="${params.chatType}.js"
profile="[email: '${params.username}2@example.com']"
/>
```

[chatTypes which are Javascripts can be found here](https://github.com/vahidhedayati/testwschat/tree/master/grails-app/assets/javascripts)

This now loads in a specific style of menus for the end chat user, you can customise further

```
wschatjs="${params.wschatjs}.js"
```

Pass in wschatjs="something" to override plugin main core wschat.js functionality in your local code. The jquery, addLayouts jqueryui bootstrap have now been added as a new functionality that you can use in <chat:includeStyle or <chat:includeAllStyle - by default their all true you can either set them as ${false} or 'false' to disable a given set of core scripts. This is since you may have your own bootstrap or jquery-ui etc already built in. In which case you would use <chat:includeStyle ... If you wanted to overrider your grails application look feel then use <chat:includeAllStyle.



#### STUN Server, setting up your own server:
Expand Down Expand Up @@ -190,3 +235,7 @@ Since 0.20+ ui.videobox has been added, earlier versions and even current versio
### Complete site wrapper example
[example chat web application with Bootstrap/Shiro:LDAP/AD](https://github.com/vahidhedayati/kchat)

[Demo of customised chat views and client/server Grails 2.4.4](https://github.com/vahidhedayati/testwschat)

[Demo of customised chat views and client/server Grails 3.0.1](https://github.com/vahidhedayati/testwschat3)

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {
id "com.jfrog.bintray" version "1.1"
}

version "3.0.1"
version "3.0.2"
group "org.grails.plugins"

apply plugin: 'maven-publish'
Expand Down
149 changes: 67 additions & 82 deletions grails-app/controllers/grails/plugin/wschat/WsChatController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package grails.plugin.wschat

import grails.converters.JSON
import org.grails.plugins.web.taglib.ApplicationTagLib
import grails.plugin.wschat.beans.ConnectTagBean
import grails.plugin.wschat.beans.InitiationBean
import grails.plugin.wschat.beans.LoginBean
import grails.plugin.wschat.beans.RoomBean
import grails.plugin.wschat.beans.SearchBean
import grails.plugin.wschat.beans.UserBean

import java.util.Map

Expand All @@ -14,68 +20,60 @@ class WsChatController extends WsChatConfService {
def wsChatBookingService
def wsChatContService

def index(ConnectTagBean bean) {
bean.addLayouts=true
bean.rooms = config.rooms as ArrayList

def sendfile(String room) {
def chatuser = session.wschatuser
boolean sender = false
if (room == chatuser) {
sender = true
if (!bean.rooms && (bean.dbSupport)) {
bean.rooms = wsChatRoomService.returnRoom(bean.dbSupport)
}
if (bean.process) {
render "Default sign in page disabled"
return
}
render view: 'sendfile', model: [sender:sender, room:room, hostname:wsconf.hostname, chatuser:chatuser, chatTitle:wsconf.chatTitle,
addAppName:wsconf.addAppName]
[bean:bean, rooms:bean.rooms]
}

def chat(ConnectTagBean bean) {
bean.setAddLayouts(true)
bean.chatuser = session.wschatuser
bean.room = session.wschatroom ?: wsChatRoomService.returnRoom(bean.dbSupport, true)
[bean:bean]
}
def sendmedia(String room) {
def chatuser = session.wschatuser

def sendfile(RoomBean bean) {
bean.chatuser = session.wschatuser
boolean sender = false
if (room == chatuser) {
sender = true
if (bean.room == bean.chatuser) {
bean.sender = true
}
render view: 'sendmedia', model: [sender:sender, room:room, hostname:wsconf.hostname, chatuser:chatuser, chatTitle:wsconf.chatTitle,
addAppName:wsconf.addAppName]
[bean:bean]
}

def index() {
def room = config.rooms
if (!room && (wsconf.dbSupport=='yes')) {
room = wsChatRoomService.returnRoom(wsconf.dbSupport as String)
} else if (!room && (wsconf.dbSupport=='no')) {
room = ['wschat']
}
if (wsconf.process.toLowerCase().equals('yes')) {
render "Default sign in page disabled"
def sendmedia(RoomBean bean) {
bean.chatuser = session.wschatuser
boolean sender = false
if (bean.room == bean.chatuser) {
bean.sender = true
}

render view: 'index', model: [chatTitle:wsconf.chatTitle,chatHeader:wsconf.chatHeader,room:room]
[bean:bean]
}

def login(String username,String room) {
String errors
if (wsconf.process.toLowerCase().equals('yes')) {
def login(LoginBean bean) {
if (bean.process) {
render "Default sign in page disabled"
return
}
username = username.trim().replace(' ', '_').replace('.', '_')
if (errors) {
flash.message = errors
if (!bean.validate()) {
flash.message = bean.errors
redirect(controller: "wsChat",action: "index")
return
}else{
session.wschatuser = username
session.wschatroom = room
session.wschatuser = bean.username
session.wschatroom = bean.room
redirect(controller: "wsChat", action: "chat")
return
}
//redirect (uri : "/wsChat/chat/${room}")
}

def chat() {
def chatuser = session.wschatuser
def room = session.wschatroom
String debug = config.debug ?: 'off'
if (!room) {
room = wsChatRoomService.returnRoom(wsconf.dbSupport as String)
}
render view: 'chat', model: [showtitle:wsconf.showtitle.toLowerCase(), dbsupport:wsconf.dbSupport.toLowerCase() , room:room,
chatuser:chatuser, chatTitle:wsconf.chatTitle,chatHeader:wsconf.chatHeader,
now:new Date(), hostname:wsconf.hostname, addAppName: wsconf.addAppName, debug:debug]
}

def verifyprofile(String username) {
Expand Down Expand Up @@ -144,54 +142,42 @@ class WsChatController extends WsChatConfService {

def confirmBan(String username,String duration,String period) {
if (isAdmin) {
render view: 'confirmBan', model: [username:username,duration:duration,period:period]
[username:username,duration:duration,period:period]
}
}

def camsend(String user) {
render view: 'camsend', model: [user:user, chatTitle:wsconf.chatTitle, hostname:wsconf.hostname, addAppName:wsconf.addAppName]
def camsend(UserBean bean) {
[bean:bean]
}

def webrtcsend(String user, String rtc) {
render view: 'webrtcsend', model: [user:user, chatTitle:wsconf.chatTitle, hostname:wsconf.hostname, iceservers:wsconf.iceservers,
addAppName:wsconf.addAppName, rtc:rtc]
def webrtcsend(UserBean bean) {
[bean:bean]
}

def webrtcrec(String user, String rtc) {
def chatuser = session.wschatuser
render view: 'webrtcrec', model: [user:user, hostname:wsconf.hostname, chatuser:chatuser, chatTitle:wsconf.chatTitle,
iceservers:wsconf.iceservers, addAppName:wsconf.addAppName, rtc:rtc]
def webrtcrec(UserBean bean) {
bean.chatuser = session.wschatuser
[bean:bean]
}

def camrec(String user) {
def chatuser = session.wschatuser
render view: 'camrec', model: [user:user, hostname:wsconf.hostname, chatuser:chatuser, chatTitle:wsconf.chatTitle,
addAppName:wsconf.addAppName]
def camrec(UserBean bean) {
bean.chatuser = session.wschatuser
[bean:bean]
}

def autocomplete() {
render autoCompleteService.autocomplete(params)
}


def viewUsers(Integer max, String s) {
def viewUsers(SearchBean bean) {
if (isAdmin) {
params.order = params.order ?: 'desc'
int total = 0
String pageSizes = params.pageSizes ?: '10'
String order = params.order ?: "desc"
String sortby = params.sortby ?: "lastUpdated"
int offset = (params.offset ?: '0') as int
def inputid = params.id
params.max = Math.min(max ?: 10, 1000)
def uList = wsChatUserService.genAllUsers()
Map vu = wsChatContService.viewUsers(s ?: '', sortby, order, offset, params.max , inputid)
s = vu.s
def foundRec = vu.foundRec
total = vu.total
def model = [userList: foundRec, userListCount: total, divupdate: 'adminsContainer',
pageSizes: pageSizes, offset: offset,inputid: inputid, s: s, order: order,
sortby:sortby, action: 'list', allcat:ChatUser.list(), max:max, params:params, uList:uList]
bean.uList = wsChatUserService.genAllUsers()
def gUsers = wsChatContService.viewUsers(bean.s ?: '', bean.sortby, bean.order, bean.offset, bean.max , bean.inputid)
bean.s = gUsers.s
bean.userList = gUsers.foundRec
bean.userListCount = gUsers.total
bean.allcat=ChatUser.list()
Map model = [bean:bean]
if (request.xhr) {
render (template: '/admin/viewUsers', model: model)
}
Expand All @@ -205,7 +191,7 @@ class WsChatController extends WsChatConfService {
def search(String mq) {
if (isAdmin) {
Map ss = wsChatUserService.search(mq)
render (template: '/admin/userList', model: [ userList: ss.userList,uList:ss.uList])
render (template: '/admin/userList', model: [bean:[userList:ss.userList, uList:ss.uList]])
}
render ''
}
Expand All @@ -215,13 +201,13 @@ class WsChatController extends WsChatConfService {
def returnResult = wsChatUserService.findaUser(uid)
render returnResult as JSON
}
render ''
}

def addUser(String username) {
if (isAdmin) {
render (template: '/admin/addUser', model: [ username:username])
}
render ''
}

def addEmail(String username) {
Expand Down Expand Up @@ -249,7 +235,7 @@ class WsChatController extends WsChatConfService {
session.wschatroom = room
redirect(controller: "wsChat", action: "chat")
}
render view: 'joinBooking', model: [startDate:startDate, endDate:endDate]
[startDate:startDate, endDate:endDate]
}

def addBooking(){
Expand All @@ -275,7 +261,6 @@ class WsChatController extends WsChatConfService {
if (isAdmin) {
render template : '/room/addaRoom'
}
render ''
}

def delaRoom() {
Expand Down Expand Up @@ -319,4 +304,4 @@ class WsChatController extends WsChatConfService {
private Boolean getIsAdmin() {
wsChatUserService.validateAdmin(session.wschatuser)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AutoCompleteService {
order('username', 'asc')
}
}
results = results?.collect { [label:it.username] }?.unique()
results = results?.collect {[label:it.username]}?.unique()
return results as JSON
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class WsChatConfService implements UserMaps, GrailsApplicationAware {
public String CHATAPP = "WsChatEndpoint"
public String CHATVIEW = "wsChat"

static final Set<HashMap<String[],String[]>> clientMaster = ([:] as Set).asSynchronized()
static final Set<HashMap<String[],String[]>> clientSlave = ([:] as Set).asSynchronized()
//static final Set<HashMap<String[],String[]>> clientMaster = ([:] as Set).asSynchronized()
//static final Set<HashMap<String[],String[]>> clientSlave = ([:] as Set).asSynchronized()

//private String dbSupport
//private JSON iceservers
Expand Down Expand Up @@ -172,8 +172,4 @@ class WsChatConfService implements UserMaps, GrailsApplicationAware {
// return grailsApplication?.config?.wschat ?: ''
//return wschat
//}




}

0 comments on commit 1486068

Please sign in to comment.