chat

How to properly listen for MultiUserChat in Smack?

孤街浪徒 提交于 2019-12-01 09:29:50
I'm not sure how to properly listen for MultiUserChats, since there are apparently two different ways to listen for them. The first way is to add a MessageListener for each room, like this: MultiUserChat muc = new MultiUserChat(connection,"MyGroup"); muc.addMessageListener(new PacketListener() { @Override public void processPacket(Packet packet) throws NotConnectedException { // TODO Auto-generated method stub } }); The second way is to listen as you would for normal single-chat messages: PacketFilter filter = new MessageTypeFilter(Message.Type.groupchat); connection.addPacketListener(new

How to know if the user is still online on the website or offline?

梦想的初衷 提交于 2019-12-01 08:27:53
问题 I am building a chat system in an asp.net MVC website, if the user has no actions on the website for more than 2 minutes I will set his status to away. My question is, how to know if the user is offline, offline means he closed the website or signer out. I knew that there is an isOnline property in the Membership classes but I am not using Membership for secure login in this website. Is there a way to know if the user is online or not, Or how this membership.IsOnline is implemented to make

看完让你彻底搞懂Websocket原理

☆樱花仙子☆ 提交于 2019-12-01 08:23:28
看完让你彻底搞懂Websocket原理 偶然在知乎上看到一篇回帖,瞬间觉得之前看的那么多资料都不及这一篇回帖让我对 websocket 的认识深刻有木有。所以转到我博客里,分享一下。比较喜欢看这种博客,读起来很轻松,不枯燥,没有布道师的阵仗,纯粹为分享。废话这么多了,最后再赞一个~ 一、websocket与http WebSocket是HTML5出的东西(协议),也就是说HTTP协议没有变化,或者说没关系,但HTTP是不支持持久连接的(长连接,循环连接的不算) 首先HTTP有 1.1 和 1.0 之说,也就是所谓的 keep-alive ,把多个HTTP请求合并为一个,但是 Websocket 其实是一个新协议,跟HTTP协议基本没有关系,只是为了兼容现有浏览器的握手规范而已,也就是说它是HTTP协议上的一种补充可以通过这样一张图理解 有交集,但是并不是全部。 另外Html5是指的一系列新的API,或者说新规范,新技术。Http协议本身只有1.0和1.1,而且跟Html本身没有直接关系。。通俗来说,你可以用HTTP协议传输非Html数据,就是这样=。= 再简单来说,层级不一样。 二、Websocket是什么样的协议,具体有什么优点 首先,Websocket是一个持久化的协议,相对于HTTP这种非持久的协议来说。简单的举个例子吧,用目前应用比较广泛的PHP生命周期来解释。

SASL Authentication failed while integrating facebook chat using Smack

删除回忆录丶 提交于 2019-12-01 06:48:46
I am trying to integrate facebook chat using smack API.But i get an error telling authentication failed using digest md5... Here s the code for authentication: SASLAuthentication.registerSASLMechanism("DIGEST-MD5", SASLDigestMD5Mechanism.class); SASLAuthentication.supportSASLMechanism("DIGEST-MD5", 0); ConnectionConfiguration config = new ConnectionConfiguration("chat.facebook.com",5222); connection = new XMPPConnection(config); config.setSASLAuthenticationEnabled(true); connection.connect(); connection.login(userName, password); below is the error i get wen i run it: Exception in thread "main

Atmosphere responses, broadcasts do not call javascript onMessage handler

余生颓废 提交于 2019-12-01 06:08:22
问题 I'm working with atmosphere trying to get the simple base implementation using atmosphere 2.0.3 tomcat 7.0.42 running locally in my eclipse environment (also connecting from external machine to see traffic with wireshark). The problem I am experiencing is no matter what transport I use, websocket, sse, polling, long-polling, the broadcast response never seems to get to the client and the response.OnMessage handler is never invoked. I receive no exceptions during runtime, and I have tried with

How to properly listen for MultiUserChat in Smack?

感情迁移 提交于 2019-12-01 06:06:47
问题 I'm not sure how to properly listen for MultiUserChats, since there are apparently two different ways to listen for them. The first way is to add a MessageListener for each room, like this: MultiUserChat muc = new MultiUserChat(connection,"MyGroup"); muc.addMessageListener(new PacketListener() { @Override public void processPacket(Packet packet) throws NotConnectedException { // TODO Auto-generated method stub } }); The second way is to listen as you would for normal single-chat messages:

how to check if database is updated with php and ajax?

孤街醉人 提交于 2019-12-01 05:29:08
问题 I am making a chat box, everything is working fine, except the update thing. I am currently refreshing the page every 3 sec to check any new messages, but it will surely cause a massive load on server and is not elegant. What i want is, chat box will check for new messages only when database is updated, rather than the timer of checking database after every 3 sec 回答1: You want AJAX push (server sends update to client only when there's something new). See an example here: http://provatosys.com

测试用例

旧街凉风 提交于 2019-12-01 04:25:18
成就大师你就看vn 1 <?php 2 namespace app\index\controller; 3 4 use think\Controller; 5 use think\Db; 6 use think\Picture; 7 8 class Chat extends Controller 9 { 10 public function privateChat() 11 { 12 $id = $this->request->param('id'); 13 14 if(!$id){ 15 $this->error('请求错误,请重新登录'); 16 } 17 $res = Db::name('accounts')->where(['id'=>$id,'status'=>1])->field('type,info_id,id')->find(); 18 $head = new Circle(); 19 $re = $head->adopt_id_get_userInfo($id); 20 $res['name'] = $re['cname']; 21 $res['photo']= $re['photo']; 22 23 24 $user = session('da'); 25 Db::name('chat_record')->where(['form'=>$user['id'],

Android - Sockets vs Polling

自古美人都是妖i 提交于 2019-12-01 03:44:37
问题 As part of an Android app I'm developing there is a chat room feature. We have a server which can process the incoming messages and store the messages. Is it better to keep a socket connection open between the phone and the server so the server can send any new messages to the phone, or is it better for the phone to poll the server for new chat messages? 回答1: It is bad solution with poll for app that have randomly posting data. What I want to say is that polling data is useful when you have

To use or not to use Data transfer objects(DTO) in a Web Api Chat Application Backend Server

爱⌒轻易说出口 提交于 2019-12-01 03:14:57
I have a chat application backend built using Web Api where I am exposing several database entities directly to clients. I was wondering whether there is any positive points to map the entities to DTOs or should I continue exposing the entities as I am currently. Just to clarify I am not asking a DTO vs non-DTO general question but just advantages of using it in this scenario since most of the fields in the entities would probably be used by the client. Yes, you can expose your entities if this is a small application developed by one person and you only have few days to finish it. If you