Search in sources :

Example 1 with InstantMessage

use of org.olat.instantMessaging.InstantMessage in project OpenOLAT by OpenOLAT.

the class ChatController method doSendMessage.

private InstantMessage doSendMessage(String text) {
    boolean anonym;
    String fromName;
    if (rosterCtrl != null) {
        anonym = rosterCtrl.isUseNickName();
        fromName = rosterCtrl.getNickName();
    } else {
        anonym = false;
        fromName = userManager.getUserDisplayName(getIdentity());
    }
    InstantMessage message;
    if (privateReceiverKey == null) {
        message = imService.sendMessage(getIdentity(), fromName, anonym, text, getOlatResourceable());
    } else {
        message = imService.sendPrivateMessage(getIdentity(), privateReceiverKey, text, getOlatResourceable());
    }
    return message;
}
Also used : InstantMessage(org.olat.instantMessaging.InstantMessage)

Example 2 with InstantMessage

use of org.olat.instantMessaging.InstantMessage in project OpenOLAT by OpenOLAT.

the class ChatController method processInstantMessageEvent.

private void processInstantMessageEvent(InstantMessagingEvent event) {
    if ("message".equals(event.getCommand())) {
        Long from = event.getFromId();
        if (!getIdentity().getKey().equals(from)) {
            Long messageId = event.getMessageId();
            InstantMessage message = imService.getMessageById(getIdentity(), messageId, true);
            appendToMessageHistory(message, false);
        }
    } else if ("participant".equals(event.getCommand())) {
        if (event.getFromId() != null) {
            updateRosterList(event.getFromId(), event.getName(), event.isAnonym(), event.isVip());
        }
    }
}
Also used : InstantMessage(org.olat.instantMessaging.InstantMessage)

Example 3 with InstantMessage

use of org.olat.instantMessaging.InstantMessage in project OpenOLAT by OpenOLAT.

the class ChatController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == chatPanelCtr) {
        fireEvent(ureq, new CloseInstantMessagingEvent(getOlatResourceable()));
        allChats.remove(Integer.toString(hashCode()));
        jsc.setRefreshIntervall(5000);
    } else if (source == sendMessageForm) {
        if (StringHelper.containsNonWhitespace(sendMessageForm.getMessage())) {
            InstantMessage message = doSendMessage(sendMessageForm.getMessage());
            appendToMessageHistory(message, true);
            sendMessageForm.resetTextField();
        } else {
            // ignore empty manObjectessage entry and refocus on entry field
            chatMsgFieldContent.contextPut("chatMessages", messageHistory);
            chatMsgFieldContent.contextPut("focus", Boolean.TRUE);
        }
    } else if (source == rosterCtrl) {
        doSendPresence(rosterCtrl.getNickName(), rosterCtrl.isUseNickName());
    }
}
Also used : CloseInstantMessagingEvent(org.olat.instantMessaging.CloseInstantMessagingEvent) InstantMessage(org.olat.instantMessaging.InstantMessage)

Example 4 with InstantMessage

use of org.olat.instantMessaging.InstantMessage in project OpenOLAT by OpenOLAT.

the class InstantMessagingServiceImpl method sendPrivateMessage.

@Override
public InstantMessage sendPrivateMessage(Identity from, Long toIdentityKey, String body, OLATResourceable chatResource) {
    String name = userManager.getUserDisplayName(from);
    InstantMessage message = imDao.createMessage(from, name, false, body, chatResource);
    imDao.createNotification(from.getKey(), toIdentityKey, chatResource);
    // commit before sending event
    dbInstance.commit();
    InstantMessagingEvent event = new InstantMessagingEvent("message", chatResource);
    event.setFromId(from.getKey());
    event.setName(name);
    event.setAnonym(false);
    event.setMessageId(message.getKey());
    // general event
    coordinator.getCoordinator().getEventBus().fireEventToListenersOf(event, chatResource);
    // buddy event
    OLATResourceable buddy = OresHelper.createOLATResourceableInstance("Buddy", toIdentityKey);
    coordinator.getCoordinator().getEventBus().fireEventToListenersOf(event, buddy);
    return message;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) InstantMessage(org.olat.instantMessaging.InstantMessage) InstantMessagingEvent(org.olat.instantMessaging.InstantMessagingEvent)

Example 5 with InstantMessage

use of org.olat.instantMessaging.InstantMessage in project openolat by klemens.

the class ChatController method doSendMessage.

private InstantMessage doSendMessage(String text) {
    boolean anonym;
    String fromName;
    if (rosterCtrl != null) {
        anonym = rosterCtrl.isUseNickName();
        fromName = rosterCtrl.getNickName();
    } else {
        anonym = false;
        fromName = userManager.getUserDisplayName(getIdentity());
    }
    InstantMessage message;
    if (privateReceiverKey == null) {
        message = imService.sendMessage(getIdentity(), fromName, anonym, text, getOlatResourceable());
    } else {
        message = imService.sendPrivateMessage(getIdentity(), privateReceiverKey, text, getOlatResourceable());
    }
    return message;
}
Also used : InstantMessage(org.olat.instantMessaging.InstantMessage)

Aggregations

InstantMessage (org.olat.instantMessaging.InstantMessage)14 IOException (java.io.IOException)4 ObjectOutputStream (java.io.ObjectOutputStream)4 InstantMessagingEvent (org.olat.instantMessaging.InstantMessagingEvent)4 File (java.io.File)2 FileWriter (java.io.FileWriter)2 OutputStream (java.io.OutputStream)2 Writer (java.io.Writer)2 Date (java.util.Date)2 Translator (org.olat.core.gui.translator.Translator)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)2 OpenXMLWorkbookResource (org.olat.core.util.openxml.OpenXMLWorkbookResource)2 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)2 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)2 CloseInstantMessagingEvent (org.olat.instantMessaging.CloseInstantMessagingEvent)2