WindChat/windchat-common/src/main/java/com/windchat/common/channel/ChannelSession.java

103 lines
2.4 KiB
Java
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Copyright 2018-2028 WindChat Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.windchat.common.channel;
import com.windchat.common.constant.RequestAction;
import io.netty.channel.Channel;
/**
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2018-01-31 12:26:53
*/
public class ChannelSession {
private String userId; // 用户在站点的siteUserId每个站点id不同区别globalUserId
private String deviceId;// 用户当前设备号
private Channel channel;// 用户当前连接的channel
private int ctype;// 1:IM 2:APi 3:WS
private long psnTime = 0;// 发送给用户PSN时间戳
private long synFinTime = 0;// 用户同步消息结束时间
public ChannelSession(Channel channel) {
this.channel = channel;
}
public ChannelSession(String userId, Channel channel) {
this.userId = userId;
this.channel = channel;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Channel getChannel() {
return channel;
}
public void setChannel(Channel channel) {
this.channel = channel;
}
public int getCtype() {
return ctype;
}
public void setCtype(int ctype) {
this.ctype = ctype;
}
public long getPsnTime() {
return psnTime;
}
public void setPsnTime(long psnTime) {
this.psnTime = psnTime;
}
public long getSynFinTime() {
return synFinTime;
}
public void setSynFinTime(long synFinTime) {
this.synFinTime = synFinTime;
}
public boolean detectPsn() {
return synFinTime <= psnTime;
}
public void setActionForPsn(String action) {
if (RequestAction.IM_SYNC_FINISH.getName().equals(action)) {
this.synFinTime = System.currentTimeMillis();
} else if (RequestAction.IM_STC_PSN.getName().equals(action)) {
this.psnTime = System.currentTimeMillis();
}
}
}