Commit 547a26bb authored by sheteng's avatar sheteng

调完了

parent dae6490e
...@@ -42,15 +42,16 @@ public class FirstFragment extends Fragment { ...@@ -42,15 +42,16 @@ public class FirstFragment extends Fragment {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
String appKey = "c981adfde9c4000"; String appKey = "c981adfde9c4000";
String userName = "user100"; String userName = "user101";
Long userId = 100L; Long userId = 101L;
String extData = "extData";
Long ts = System.currentTimeMillis(); Long ts = System.currentTimeMillis();
String data = appKey + "&" + userId + "&" + userName + "&" + ts + String data = appKey + "&" + userId + "&" + userName + "&" + extData + "&" + ts +
"&wW7cR31PwJseIoZMOs311nljHpwUmujs"; "&wW7cR31PwJseIoZMOs311nljHpwUmujs";
//sign计算在服务器,本地不要暴露appsecrect
String sign = HmacUtil.stringToSign("wW7cR31PwJseIoZMOs311nljHpwUmujs",data); String sign = HmacUtil.stringToSign("wW7cR31PwJseIoZMOs311nljHpwUmujs",data);
CCIMClient.getInstance().initSDK(appKey, userName, 100L, ts, sign, new OnConnectListener() { CCIMClient.getInstance().initSDK(appKey, userName, extData,101L, ts, sign, new OnConnectListener() {
@Override @Override
public void onSocketConnection() { public void onSocketConnection() {
refreshLogView("connect success"); refreshLogView("connect success");
...@@ -61,6 +62,7 @@ public class FirstFragment extends Fragment { ...@@ -61,6 +62,7 @@ public class FirstFragment extends Fragment {
refreshLogView("disconnect"); refreshLogView("disconnect");
} }
}); });
CCIMClient.getInstance().registerMessageListener(new ResultEventCallback<Chat.ChatResponseMessage>() { CCIMClient.getInstance().registerMessageListener(new ResultEventCallback<Chat.ChatResponseMessage>() {
@Override @Override
public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) { public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) {
...@@ -130,7 +132,7 @@ public class FirstFragment extends Fragment { ...@@ -130,7 +132,7 @@ public class FirstFragment extends Fragment {
binding.sendTextMessage.setOnClickListener(new View.OnClickListener() { binding.sendTextMessage.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CCIMClient.getInstance().sendTextMessage("你好", Long.parseLong(binding.userId.getText().toString()), new ResultCallback() { CCIMClient.getInstance().sendTextMessage(binding.msg.getText().toString(), Long.parseLong(binding.userId.getText().toString()), new ResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
refreshLogView("sendTextMessage success"); refreshLogView("sendTextMessage success");
...@@ -174,17 +176,17 @@ public class FirstFragment extends Fragment { ...@@ -174,17 +176,17 @@ public class FirstFragment extends Fragment {
} }
}); });
// binding.moveContactGroupRequest.setOnClickListener(new View.OnClickListener() { binding.moveContactGroupRequest.setOnClickListener(new View.OnClickListener() {
// @Override @Override
// public void onClick(View v) { public void onClick(View v) {
// CCIMClient.getInstance().moveContactGroup(Long.parseLong(binding.groupId.getText().toString()), Long.parseLong(binding.userId.getText().toString()), new ResultCallback() { CCIMClient.getInstance().moveContactGroup(Long.parseLong(binding.groupId.getText().toString()), Long.parseLong(binding.userId.getText().toString()), new ResultCallback() {
// @Override @Override
// public void onSuccess() { public void onSuccess() {
// refreshLogView("moveContactGroupRequest success " ); refreshLogView("moveContactGroupRequest success " );
// } }
// }); });
// } }
// }); });
binding.deleteContact.setOnClickListener(new View.OnClickListener() { binding.deleteContact.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -226,7 +228,7 @@ public class FirstFragment extends Fragment { ...@@ -226,7 +228,7 @@ public class FirstFragment extends Fragment {
binding.sendChannelMessage.setOnClickListener(new View.OnClickListener() { binding.sendChannelMessage.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CCIMClient.getInstance().sendChannelMessage("搞黄色", Long.parseLong(binding.channelId.getText().toString()), new ResultCallback() { CCIMClient.getInstance().sendChannelMessage(binding.msg.getText().toString(), Long.parseLong(binding.channelId.getText().toString()), new ResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
refreshLogView("sendChannelMessage success"); refreshLogView("sendChannelMessage success");
...@@ -238,7 +240,6 @@ public class FirstFragment extends Fragment { ...@@ -238,7 +240,6 @@ public class FirstFragment extends Fragment {
binding.startRecordAudioMessage.setOnClickListener(new View.OnClickListener() { binding.startRecordAudioMessage.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CCIMClient.getInstance().startRecordAudioMessage(getActivity()); CCIMClient.getInstance().startRecordAudioMessage(getActivity());
} }
}); });
...@@ -256,6 +257,56 @@ public class FirstFragment extends Fragment { ...@@ -256,6 +257,56 @@ public class FirstFragment extends Fragment {
} }
}); });
binding.createChannel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ArrayList<Long> userIds = new ArrayList<>();
userIds.add(Long.parseLong(binding.userId.getText().toString()));
CCIMClient.getInstance().createChannel("大世界", "112", false,userIds, new ResultEventCallback<Long>() {
@Override
public void onSuccess(Long aLong) {
binding.channelId.setText(aLong.toString());
refreshLogView("createChannel " + aLong);
}
});
}
});
binding.joinChannel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CCIMClient.getInstance().joinChannel(Long.parseLong(binding.channelId.getText().toString()), new ResultCallback() {
@Override
public void onSuccess() {
refreshLogView("joinChannel ");
}
});
}
});
binding.removeChannelMember.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CCIMClient.getInstance().removeChannelMember(Long.parseLong(binding.channelId.getText().toString()), Long.parseLong(binding.userId.getText().toString()), new ResultCallback() {
@Override
public void onSuccess() {
refreshLogView("removeChannelMember: ");
}
});
}
});
binding.exitChannel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CCIMClient.getInstance().exitChannel(Long.parseLong(binding.channelId.getText().toString()), new ResultCallback() {
@Override
public void onSuccess() {
refreshLogView("exitChannel: ");
}
});
}
});
} }
......
...@@ -28,7 +28,19 @@ ...@@ -28,7 +28,19 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="userId" android:hint="userId"
android:text="2" /> android:text="103" />
<TextView
android:layout_width="wrap_content"
android:text="groupId"
android:layout_height="wrap_content"/>
<EditText
android:id="@+id/groupId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="channelId"
android:text="1" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -40,9 +52,16 @@ ...@@ -40,9 +52,16 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="channelId" android:hint="channelId"
android:text="1" /> android:text="6857982583817506816" />
</LinearLayout> </LinearLayout>
<EditText
android:id="@+id/msg"
android:layout_width="match_parent"
android:hint="msg"
android:text="nihao"
android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
...@@ -172,6 +191,36 @@ ...@@ -172,6 +191,36 @@
android:text="举报违规用户" /> android:text="举报违规用户" />
<Button
android:id="@+id/createChannel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="创建频道" />
<Button
android:id="@+id/joinChannel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="加入频道" />
<Button
android:id="@+id/removeChannelMember"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="移除频道成员" />
<Button
android:id="@+id/exitChannel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="退出频道" />
<Button <Button
android:id="@+id/sendChannelMessage" android:id="@+id/sendChannelMessage"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -186,6 +235,7 @@ ...@@ -186,6 +235,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:visibility="gone"
android:text="开始录音" /> android:text="开始录音" />
<Button <Button
...@@ -194,6 +244,7 @@ ...@@ -194,6 +244,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:visibility="gone"
android:text="录音上传" /> android:text="录音上传" />
<Button <Button
...@@ -202,6 +253,7 @@ ...@@ -202,6 +253,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:visibility="gone"
android:text="取消上传" /> android:text="取消上传" />
......
...@@ -16,6 +16,8 @@ import com.permissionx.guolindev.PermissionX; ...@@ -16,6 +16,8 @@ import com.permissionx.guolindev.PermissionX;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import ccim.protocol.Channel;
import ccim.protocol.Chat; import ccim.protocol.Chat;
import ccim.protocol.Message; import ccim.protocol.Message;
import ccim.protocol.MessageSpec; import ccim.protocol.MessageSpec;
...@@ -44,10 +46,10 @@ public class CCIMClient { ...@@ -44,10 +46,10 @@ public class CCIMClient {
return mInstance; return mInstance;
} }
public void initSDK(String appKey, String userName, Long userId, Long ts, String sign, OnConnectListener resultCallback) { public void initSDK(String appKey, String userName,String extData, Long userId, Long ts, String sign, OnConnectListener resultCallback) {
callBackManager = new CallBackManager<>(); callBackManager = new CallBackManager<>();
socketManageer = new SocketManageer(callBackManager); socketManageer = new SocketManageer(callBackManager);
socketManageer.initChat(appKey, userName, userId,ts,sign,resultCallback); socketManageer.initChat(appKey, userName,extData, userId,ts,sign,resultCallback);
} }
...@@ -355,7 +357,6 @@ public class CCIMClient { ...@@ -355,7 +357,6 @@ public class CCIMClient {
@Override @Override
public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) { public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) {
if (chatResponseMessage.hasSendMsgRes()) { if (chatResponseMessage.hasSendMsgRes()) {
logger.info(String.valueOf(chatResponseMessage.getSearchRes()));
callback.onSuccess(); callback.onSuccess();
} }
} }
...@@ -367,8 +368,109 @@ public class CCIMClient { ...@@ -367,8 +368,109 @@ public class CCIMClient {
}); });
} }
/**
* 创建频道
*/
public void createChannel(String channelName,String tag,boolean isOpen,List<Long> userIds, ResultEventCallback<Long> callback) {
Channel.CreateChannelRequest.Builder builder = Channel.CreateChannelRequest.newBuilder()
.setName(channelName)
.setTag(tag)
.setOpen(isOpen);
for (Long id : userIds) {
builder.addUserIds(id);
}
int id = socketManageer.sendRequest(builder.build());
callBackManager.addCallBack(id, new ResultEventCallback<Chat.ChatResponseMessage>() {
@Override
public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) {
if (chatResponseMessage.hasCreateChannelRes()) {
logger.info(String.valueOf(chatResponseMessage));
Channel.CreateChannelResponse createChannelRes = chatResponseMessage.getCreateChannelRes();
callback.onSuccess(createChannelRes.getChannelId());
}
}
@Override
public void onFailed(int errorCode) {
callback.onFailed(errorCode);
}
});
}
/**
* 加入频道
*/
public void joinChannel(Long channelId, ResultCallback callback) {
Channel.JoinChannelRequest.Builder builder = Channel.JoinChannelRequest.newBuilder()
.setChannelId(channelId);
int id = socketManageer.sendRequest(builder.build());
callBackManager.addCallBack(id, new ResultEventCallback<Chat.ChatResponseMessage>() {
@Override
public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) {
if (chatResponseMessage.hasJoinChannelRes()) {
logger.info(String.valueOf(chatResponseMessage));
callback.onSuccess();
}
}
@Override
public void onFailed(int errorCode) {
callback.onFailed(errorCode);
}
});
}
/**
* 移除频道成员
*/
public void removeChannelMember(Long channelId,Long userId, ResultCallback callback) {
Channel.RemoveMemberRequest.Builder builder = Channel.RemoveMemberRequest.newBuilder()
.setChannelId(channelId)
.setUserId(userId);
int id = socketManageer.sendRequest(builder.build());
callBackManager.addCallBack(id, new ResultEventCallback<Chat.ChatResponseMessage>() {
@Override
public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) {
if (chatResponseMessage.hasRemoveMemberRes()) {
logger.info(String.valueOf(chatResponseMessage));
callback.onSuccess();
}
}
@Override
public void onFailed(int errorCode) {
callback.onFailed(errorCode);
}
});
}
/**
* 退出频道
*/
public void exitChannel(Long channelId, ResultCallback callback) {
Channel.ExitChannelRequest.Builder builder = Channel.ExitChannelRequest.newBuilder()
.setChannelId(channelId);
int id = socketManageer.sendRequest(builder.build());
callBackManager.addCallBack(id, new ResultEventCallback<Chat.ChatResponseMessage>() {
@Override
public void onSuccess(Chat.ChatResponseMessage chatResponseMessage) {
if (chatResponseMessage.hasRemoveMemberRes()) {
logger.info(String.valueOf(chatResponseMessage));
callback.onSuccess();
}
}
@Override
public void onFailed(int errorCode) {
callback.onFailed(errorCode);
}
});
}
/** /**
* 发送群组消息 * 发送频道消息
*/ */
public void sendChannelMessage(String content, Long channelId, ResultCallback callback) { public void sendChannelMessage(String content, Long channelId, ResultCallback callback) {
Message.SendChannelMessageRequest sendChannelMessageRequest = Message.SendChannelMessageRequest.newBuilder() Message.SendChannelMessageRequest sendChannelMessageRequest = Message.SendChannelMessageRequest.newBuilder()
......
...@@ -2,5 +2,5 @@ package com.ccwangluo.ccim.listener; ...@@ -2,5 +2,5 @@ package com.ccwangluo.ccim.listener;
public interface OnConnectListener { public interface OnConnectListener {
void onSocketConnection(); void onSocketConnection();
void onSocketDisconnection(); default void onSocketDisconnection(){};
} }
...@@ -15,14 +15,17 @@ import com.xuhao.didi.socket.client.sdk.client.OkSocketOptions; ...@@ -15,14 +15,17 @@ import com.xuhao.didi.socket.client.sdk.client.OkSocketOptions;
import com.xuhao.didi.socket.client.sdk.client.action.SocketActionAdapter; import com.xuhao.didi.socket.client.sdk.client.action.SocketActionAdapter;
import com.xuhao.didi.socket.client.sdk.client.connection.IConnectionManager; import com.xuhao.didi.socket.client.sdk.client.connection.IConnectionManager;
import java.util.logging.Logger; import java.util.logging.Logger;
import ccim.protocol.Channel;
import ccim.protocol.Chat; import ccim.protocol.Chat;
import ccim.protocol.Common; import ccim.protocol.Common;
import ccim.protocol.Message; import ccim.protocol.Message;
import ccim.protocol.Push; import ccim.protocol.Push;
public class SocketManageer { public class SocketManageer {
private final Logger logger = Logger.getLogger(CCIMClient.class.getName());
private static final String SERVER_IP = "117.144.156.2"; private static final String SERVER_IP = "117.144.156.2";
// private static final String SERVER_IP = "192.168.31.216";
private static final int SERVER_PORT = 8000; private static final int SERVER_PORT = 8000;
private static final int version = 1; private static final int version = 1;
...@@ -44,11 +47,12 @@ public class SocketManageer { ...@@ -44,11 +47,12 @@ public class SocketManageer {
} }
public void connectChatServer(String appKey, String userName, Long userId,Long ts, String sign) { public void connectChatServer(String appKey, String userName,String extData, Long userId,Long ts, String sign) {
Chat.ConnectRequest builder = Chat.ConnectRequest.newBuilder() Chat.ConnectRequest builder = Chat.ConnectRequest.newBuilder()
.setUsername(userName) .setUsername(userName)
.setAppKey(appKey) .setAppKey(appKey)
.setUserId(userId) .setUserId(userId)
.setExtData(extData)
.setTs(ts) .setTs(ts)
.setSign(sign) .setSign(sign)
.build(); .build();
...@@ -64,18 +68,25 @@ public class SocketManageer { ...@@ -64,18 +68,25 @@ public class SocketManageer {
}); });
} }
public void initChat(String appKey, String userName, Long userId, Long ts, String sign, OnConnectListener resultCallback) { public void initChat(String appKey, String userName,String extData, Long userId, Long ts, String sign, OnConnectListener resultCallback) {
onConnectListener = resultCallback; onConnectListener = resultCallback;
if (chatInfo != null){
OkSocket.open(chatInfo).disconnect();
}
id = 1;
this.chatInfo = initServer(SERVER_IP, SERVER_PORT, new MessageListener() { this.chatInfo = initServer(SERVER_IP, SERVER_PORT, new MessageListener() {
@Override @Override
public void onServerConnect() { public void onServerConnect() {
connectChatServer(appKey, userName, userId,ts,sign); // if(id == 1) {
connectChatServer(appKey, userName,extData, userId, ts, sign);
// }
} }
@Override @Override
public void onMessageListener(OriginalData data) { public void onMessageListener(OriginalData data) {
try { try {
Chat.ChatResponseMessage chatResponseMessage = Chat.ChatResponseMessage.parseFrom(data.getBodyBytes()); Chat.ChatResponseMessage chatResponseMessage = Chat.ChatResponseMessage.parseFrom(data.getBodyBytes());
logger.info(chatResponseMessage.toString());
int seq = chatResponseMessage.getHeader().getSeq(); int seq = chatResponseMessage.getHeader().getSeq();
ResultEventCallback<Chat.ChatResponseMessage> callBack = callBackManager.getCallBack(seq); ResultEventCallback<Chat.ChatResponseMessage> callBack = callBackManager.getCallBack(seq);
if (callBack != null) { if (callBack != null) {
...@@ -85,10 +96,8 @@ public class SocketManageer { ...@@ -85,10 +96,8 @@ public class SocketManageer {
} else { } else {
callBack.onFailed(chatResponseMessage.getHeader().getCode().getNumber()); callBack.onFailed(chatResponseMessage.getHeader().getCode().getNumber());
} }
if (!chatResponseMessage.hasPullOfflineMsgRes()) {
callBackManager.removeCallBack(seq); callBackManager.removeCallBack(seq);
} }
}
else if (seq == 0) { //push消息 else if (seq == 0) { //push消息
callBack.onSuccess(chatResponseMessage); callBack.onSuccess(chatResponseMessage);
} }
...@@ -108,7 +117,6 @@ public class SocketManageer { ...@@ -108,7 +117,6 @@ public class SocketManageer {
//获得当前连接通道的参配对象 //获得当前连接通道的参配对象
OkSocketOptions.Builder okOptionsBuilder = new OkSocketOptions.Builder(); OkSocketOptions.Builder okOptionsBuilder = new OkSocketOptions.Builder();
okOptionsBuilder.setReaderProtocol(new MyIReaderProtocol()); okOptionsBuilder.setReaderProtocol(new MyIReaderProtocol());
// okOptionsBuilder.setConnectionHolden(false);
//将新的修改后的参配设置给连接管理器 //将新的修改后的参配设置给连接管理器
manager.option(okOptionsBuilder.build()); manager.option(okOptionsBuilder.build());
//调用通道进行连接 //调用通道进行连接
...@@ -173,6 +181,14 @@ public class SocketManageer { ...@@ -173,6 +181,14 @@ public class SocketManageer {
builder.setPushChannelMsgAckReq((Push.PushChannelMessageAckRequest) request); builder.setPushChannelMsgAckReq((Push.PushChannelMessageAckRequest) request);
} else if (request instanceof Message.PullOfflineMessageRequest){ } else if (request instanceof Message.PullOfflineMessageRequest){
builder.setPullOfflineMsgReq((Message.PullOfflineMessageRequest) request); builder.setPullOfflineMsgReq((Message.PullOfflineMessageRequest) request);
} else if (request instanceof Channel.CreateChannelRequest){
builder.setCreateChannelReq((Channel.CreateChannelRequest) request);
} else if (request instanceof Channel.JoinChannelRequest){
builder.setJoinChannelReq((Channel.JoinChannelRequest) request);
} else if (request instanceof Channel.RemoveMemberRequest){
builder.setRemoveMemberReq((Channel.RemoveMemberRequest) request);
} else if (request instanceof Channel.ExitChannelRequest){
builder.setExitChannelReq((Channel.ExitChannelRequest) request);
} }
OkSocket.open(getChatInfo()) OkSocket.open(getChatInfo())
......
package com.ccwangluo.ccim.util; package com.ccwangluo.ccim.util;
import android.util.Base64;
import android.util.Log;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import android.util.Log;
import com.google.common.base.Strings;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac; import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
......
...@@ -4,8 +4,9 @@ package ccim.protocol; ...@@ -4,8 +4,9 @@ package ccim.protocol;
message CreateChannelRequest { message CreateChannelRequest {
string name = 1; string name = 1;
bool open = 2; string tag = 2;
repeated int64 user_ids = 3; bool open = 3;
repeated int64 user_ids = 4;
} }
message CreateChannelResponse { message CreateChannelResponse {
......
...@@ -71,13 +71,15 @@ message ConnectRequest { ...@@ -71,13 +71,15 @@ message ConnectRequest {
string app_key = 1; string app_key = 1;
int64 user_id = 2; int64 user_id = 2;
string username = 3; string username = 3;
int64 ts = 4; string ext_data = 4;
string sign = 5; int64 ts = 5;
string sign = 6;
// sign使用HMAC加密算法,由接入端的服务端计算完成传给接入端的客户端 // sign使用HMAC加密算法,由接入端的服务端计算完成传给接入端的客户端
// sign = HMAC(app_secret).digestToHex(app_key&user_id&username&ts&app_secret) // sign = HMAC_SHA256(app_secret).digestToHex(app_key&user_id&username&ext_data&ts&app_secret)
// ts=CurrentTimeMillis (毫秒) // ts=CurrentTimeMillis (毫秒)
} }
message ConnectResponse { message ConnectResponse {
bool connected = 1; //是否连接成功 bool connected = 1; //是否连接成功
} }
...@@ -95,26 +97,19 @@ message PullContactsResponse { ...@@ -95,26 +97,19 @@ message PullContactsResponse {
MUTED = 1; // 拒绝接收消息 MUTED = 1; // 拒绝接收消息
BLACK_LIST = 2; // 黑名单 BLACK_LIST = 2; // 黑名单
} }
enum NetStatus {
int64 app_id = 1; // 应用id ONLINE = 0;
int64 user_id = 2; OFFLINE = 1;
int64 contact_user_id = 3; // 联系人用户id }
string contact_user_name = 4; // 联系人用户名字 int64 contact_user_id = 1; // 联系人用户id
int64 contact_group_id = 5; // 联系人群组id string contact_user_name = 2; // 联系人用户名字
int64 private_id = 6; // 私聊对话id int64 contact_group_id = 3; // 联系人群组id
int64 read_msg_id = 7; // 已读消息id int64 private_id = 4; // 私聊对话id
Status status = 8; // 联系人状态 int64 read_msg_id = 5; // 已读消息id
string ext_data = 9; // 扩展数据 Status status = 6; // 联系人状态
NetStatus net_status = 7; // 网络状态
string ext_data = 8; // 扩展数据
} }
// message Group {
// int64 group_id = 1;
// int64 app_id = 2;
// int64 owner_user_id = 3;
// int32 limited = 4;
// bool muted = 5;
// string name = 6;
// string ext_data = 7;
// }
message Channel { message Channel {
int64 channel_id = 1; int64 channel_id = 1;
int64 app_id = 2; int64 app_id = 2;
...@@ -126,7 +121,7 @@ message PullContactsResponse { ...@@ -126,7 +121,7 @@ message PullContactsResponse {
} }
repeated ContactGroup contact_groups = 2; // 联系人群组列表 repeated ContactGroup contact_groups = 2; // 联系人群组列表
repeated Contact contacts = 3; // 联系人列表 repeated Contact contacts = 3; // 联系人列表
// repeated Group groups = 4; // 群组 // repeated Group groups = 4; // 群组
repeated Channel channels = 4; // 频道 repeated Channel channels = 4; // 频道
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment