直播聊天室訊息型別

2021-08-03 16:49:40 字數 1071 閱讀 6050

直播聊天室中是使用的自定義訊息;具體的類是在customattachment資料夾裡面;主要有

customtextattachment  普通文字訊息:

customgiftattachment  禮物與優惠券訊息;

customlikeattachment  點讚訊息(暫時沒用到)

customsystemattachment  系統訊息(暫時也沒用到) 

defaultcustomattachment  其它訊息(沒有用到)

customanchorresumeattachment  一對一聊天用到的訊息型別  

customattachmenttype :介面 訊息的型別

customattachment 基類,上面的幾種自定義訊息都是繼承它;它實現了msgattachment(網易im寫的);

customattachparser :這是乙個解析類,可以將我們自定義的訊息轉成json

nimclient.getservice(msgservice.class).registercustomattachmentparser(new customattachparser());//註冊訊息解析器

}使用方法:

接收到的 

immessage message
customtextattachment attachment = (customtextattachment) message.getattachment();

強轉訊息後就可以得到裡面的內容

傳送的

customgiftattachment giftattachment = new customgiftattachment(type, count, extstr);

chatroommessage message = chatroommessagebuilder.createchatroomcustommessage(chatroomid, giftattachment);
先構造乙個attachment 物件 ,再傳送;

mysql 聊天室 聊天室php mysql 六

聊天室php mysql 六 相應的 資料庫 phpmyadmin mysql dump 主機 localhost 3306 資料庫 study28 資料表的結構 chat user create table chat user userid varchar 20 not null,passwd v...

django實現聊天室 訊息推送

在django中,預設使用的是http通訊,不過這種通訊方式有個很大的缺陷,就是不能很好的支援實時通訊。如果硬是要使用http做實時通訊的話只能在客戶端進行輪詢了,不過這樣做的開銷太大了。因此,在1.9版本之後,django實現了對channels的支援,他所使用的是websocket通訊,解決了實...

聊天室程式

伺服器 include include include include include include include include define servport 8081 伺服器端口號 define bufsize 200 最大傳輸量 int main int args,char argv s...