Skip to content

Commit

Permalink
SAK-32035 : Replace courier service in chat with some other service (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
frasese authored and ern committed Jul 20, 2017
1 parent be0c508 commit 097375a
Show file tree
Hide file tree
Showing 34 changed files with 1,695 additions and 2,477 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.sakaiproject.entity.api.EntitySummary;
import org.sakaiproject.exception.PermissionException;
Expand Down Expand Up @@ -145,20 +146,6 @@ public interface ChatManager extends EntitySummary {
* @return ChatMessage
*/
public ChatMessage getMessage(String chatMessageId);

/**
* Adds a room listener on the room
* @param observer RoomObserver the class to observe the room
* @param roomId the room being observed
*/
public void addRoomListener(RoomObserver observer, String roomId);

/**
* Removes a room listener on the room
* @param observer RoomObserver the class to stop observing the room
* @param roomId the room being observed
*/
public void removeRoomListener(RoomObserver observer, String roomId);

/**
* sends the message out to the other clients
Expand Down Expand Up @@ -264,4 +251,54 @@ public interface ChatManager extends EntitySummary {
*/
public int getMessagesMax();

/**
* Get all online users in given siteId and chat channel id
*
* @param siteId
* @param channelId
* @return
*/
public List<SimpleUser> getPresentUsers(String siteId, String channelId);

/**
* - Update heartbeat for current user
* - Get undelivered (latest) messages
* - Get online users
* - Get removed messages
*
* @param siteId
* @param channelId
* @param sessionKey
* @return
*/
public Map<String,Object> handleChatData(String siteId, String channelId, String sessionKey);

/**
* Get pollInterval (in milliseconds) from properties
* @return
*/
public int getPollInterval();

/**
* Get session key (ussage_session_id:session_user_id) from current session
* @return
*/
public String getSessionKey();

/**
* Get different date strings based on given ChatMessage::messageDate
* @param msg
* @return
*/
public MessageDateString getMessageDateString(ChatMessage msg);

/**
* Get user timezone from preferencesService.
* This method is almost a duplicate from BasicTimeService.getUserTimezoneLocale.
* Would be great if the preferencesService returns it directly
* @return
*/
public String getUserTimeZone();


}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ public void setBody(String body) {
}
this.body = formattedBody;
}

public void setRawBody(String body){
this.body = body;
}

/**
* Serialize the resource into XML, adding an element to the doc under the top of the stack element.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.sakaiproject.chat2.model;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class DeleteMessage{
private String id;
private String channelId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.sakaiproject.chat2.model;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class MessageDateString{
private String localizedDate;
private String localizedTime;
private String dateID;
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sakaiproject.chat2.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@AllArgsConstructor
@EqualsAndHashCode(of={"id"})
public class SimpleUser{
private String id;
private String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package org.sakaiproject.chat2.model;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Date;

import lombok.Data;

/**
*
* Class used to transfer data through jGroups
*
*/
@Data
public class TransferableChatMessage implements Serializable {

public enum MessageType {
CHAT,
HEARTBEAT,
CLEAR,
REMOVE;
}

public MessageType type;
public String id;
public String owner;
public String siteId;
public String channelId;
public String content;
public long timestamp;

public TransferableChatMessage(ChatMessage msg) {
this(MessageType.CHAT, msg.getId(), msg.getOwner(), msg.getChatChannel().getContext(), msg.getChatChannel().getId(), msg.getBody());
}

public TransferableChatMessage(MessageType type, String id) {
this(type, id, null, null, null, null);
}

public TransferableChatMessage(MessageType type, String id, String channelId) {
this(type, id, null, null, channelId, null);
}

public TransferableChatMessage(MessageType type, String id, String owner, String siteId, String channelId, String content) {
this.type = type;
this.id = id;
this.owner = owner;
this.siteId = siteId;
this.channelId = channelId;
this.content = content;
this.timestamp = (new Date()).getTime();
}

public static TransferableChatMessage HeartBeat(String channelId, String sessionKey){
return new TransferableChatMessage(MessageType.HEARTBEAT, sessionKey, channelId);
}

public ChatMessage toChatMessage() {
return toChatMessage(null);
}
public ChatMessage toChatMessage(ChatChannel channel) {
ChatMessage message = new ChatMessage();

message.setId(id);
message.setChatChannel(channel);
message.setOwner(owner);
message.setRawBody(content);
message.setMessageDate(new Date(timestamp));

return message;
}

public void writeObject(ObjectOutputStream out) throws IOException {
out.writeObject(type.toString());
out.writeObject(id);
out.writeObject(owner);
out.writeObject(siteId);
out.writeObject(channelId);
out.writeObject(content);
out.writeObject(timestamp);
}

public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
this.type = MessageType.valueOf((String) in.readObject());
this.id = (String) in.readObject();
this.owner = (String) in.readObject();
this.siteId = (String) in.readObject();
this.channelId = (String) in.readObject();
this.content = (String) in.readObject();
this.timestamp = (Long) in.readObject();
}
}
50 changes: 50 additions & 0 deletions chat/chat-impl/impl/conf/jgroups-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
<UDP
mcast_port="${jgroups.udp.mcast_port:45589}"
ip_ttl="4"
tos="8"
ucast_recv_buf_size="5M"
ucast_send_buf_size="5M"
mcast_recv_buf_size="5M"
mcast_send_buf_size="5M"
max_bundle_size="64K"
enable_diagnostics="true"
thread_naming_pattern="cl"

thread_pool.min_threads="0"
thread_pool.max_threads="20"
thread_pool.keep_alive_time="30000"/>

<PING />
<MERGE3 max_interval="30000"
min_interval="10000"/>
<FD_SOCK/>
<FD_ALL/>
<VERIFY_SUSPECT timeout="1500" />
<BARRIER />
<pbcast.NAKACK2 xmit_interval="500"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="2000"
xmit_table_max_compaction_time="30000"
use_mcast_xmit="false"
discard_delivered_msgs="true"/>
<UNICAST3 xmit_interval="500"
xmit_table_num_rows="100"
xmit_table_msgs_per_row="2000"
xmit_table_max_compaction_time="60000"
conn_expiry_timeout="0"/>
<pbcast.STABLE desired_avg_gossip="50000"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true" join_timeout="2000"
view_bundling="true"/>
<UFC max_credits="2M"
min_threshold="0.4"/>
<MFC max_credits="2M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K" />
<RSVP resend_interval="2000" timeout="10000"/>
<pbcast.STATE_TRANSFER />
<!-- pbcast.FLUSH /-->
</config>
Loading

0 comments on commit 097375a

Please sign in to comment.