中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

上海網(wǎng)站建設(shè)哪個(gè)平臺(tái)好百度推廣怎么優(yōu)化

上海網(wǎng)站建設(shè)哪個(gè)平臺(tái)好,百度推廣怎么優(yōu)化,在線做雅思真題網(wǎng)站,西安代做畢業(yè)設(shè)計(jì)網(wǎng)站概述 基于spingboot的websocket多人聊天系統(tǒng)。包括訂閱,廣播、點(diǎn)對(duì)點(diǎn)單人聊天,多人聊天室功能。 詳細(xì) 一、運(yùn)行效果 簡單示例 廣播 單人聊天 多人聊天室 二、相關(guān)代碼 websocket配置 package com.iamgpj.demowebsocket.config;import com.iamgpj.d…

概述

基于spingboot的websocket多人聊天系統(tǒng)。包括訂閱,廣播、點(diǎn)對(duì)點(diǎn)單人聊天,多人聊天室功能。

詳細(xì)

一、運(yùn)行效果

簡單示例

image.png

廣播

image.png

單人聊天

image.png

多人聊天室

image.png

二、相關(guān)代碼

websocket配置

package com.iamgpj.demowebsocket.config;import com.iamgpj.demowebsocket.v4.SocketChannelInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;import javax.websocket.server.ServerEndpointConfig;/*** @author Ives* @date 2020/4/20 13:51*/
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends ServerEndpointConfig.Configurator implements WebSocketMessageBrokerConfigurer {/*** 注冊端點(diǎn),發(fā)布或者訂閱消息的時(shí)候需要連接此端點(diǎn)* addEndpoint websocket的端點(diǎn),客戶端需要注冊這個(gè)端點(diǎn)進(jìn)行鏈接* setAllowedOrigins 非必須,*表示允許其他域進(jìn)行連接,跨域* withSockJS 允許客戶端利用sockjs進(jìn)行瀏覽器兼容性處理* @param registry*/@Overridepublic void registerStompEndpoints(StompEndpointRegistry registry) {registry.addEndpoint("/ws/endpoints-websocket")//.setAllowedOrigins("*").withSockJS();}/*** 配置消息代理* @param registry*/@Overridepublic void configureMessageBroker(MessageBrokerRegistry registry) {// 設(shè)置服務(wù)器廣播消息的基礎(chǔ)路徑registry.enableSimpleBroker("/topic", "/user");// 設(shè)置客戶端訂閱消息的基礎(chǔ)路徑registry.setApplicationDestinationPrefixes("/app");}/** 配置頻道攔截器,用于聊天室 */@Overridepublic void configureClientInboundChannel(ChannelRegistration registration) {registration.interceptors(new SocketChannelInterceptor());}
}

聊天室程序

package com.iamgpj.demowebsocket.v4;import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;import java.time.LocalDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;/*** @author Ives* @date 2020/4/21 11:13*/
@Service
@Slf4j
public class ChatRoomService {@Autowiredprivate SimpMessagingTemplate template;/*** 模擬數(shù)據(jù)庫中存儲(chǔ)的用戶*/public static Map<String, String> userMap = new HashMap<>();/*** 保存當(dāng)前在線用戶* 實(shí)際應(yīng)該存儲(chǔ)于redis等可持久化緩存服務(wù)器中,做到數(shù)據(jù)共享*/public static Map<String, String> onlineUserMap = new HashMap<>();/** 初始化數(shù)據(jù) */static {userMap.put("張三", "111111");userMap.put("李四", "111111");userMap.put("王五", "111111");userMap.put("趙六", "111111");userMap.put("陳七", "111111");}/*** 每兩秒給客戶端推送當(dāng)前在線用戶*/@Scheduled(fixedRate = 2000)public void pushOnlineUser() {Collection<String> users = onlineUserMap.values();log.info("【聊天室在線用戶】={}", users);template.convertAndSend("/topic/onlineUser", users);}/*** 推送聊天消息* @param inMessage 內(nèi)容*/public void pushChatRoom(InMessage inMessage) {OutMessage outMessage = new OutMessage();BeanUtils.copyProperties(inMessage, outMessage);outMessage.setPushTime(LocalDateTime.now());template.convertAndSend("/topic/chatRoom", outMessage);}
}

三、代碼結(jié)構(gòu)

image.png

四、相關(guān)說明

1、項(xiàng)目前段使用bootstrap框架,使用maven引入webjars作為樣式文件。

2、訪問路徑分別為

????http://localhost:8080/v1/index.html

????http://localhost:8080/v2/index.html

????http://localhost:8080/v3/tom.html

????http://localhost:8080/v3/jerry.html

????http://localhost:8080/v4/index.html

3、聊天室請分別使用不同瀏覽器登錄測試。登錄名可以為,張三、李四、王五、趙六....

http://www.risenshineclean.com/news/65011.html

相關(guān)文章:

  • 做啊網(wǎng)站寧德市自然資源局
  • 西安大型網(wǎng)站建設(shè)公司昆山seo網(wǎng)站優(yōu)化軟件
  • 網(wǎng)站如果不備案如何檢測網(wǎng)站是否安全
  • 成都網(wǎng)站品牌設(shè)計(jì)北京百度公司地址在哪里
  • 虛擬主機(jī)管理怎么做網(wǎng)站游戲推廣員怎么做
  • 怎么把代碼添加網(wǎng)站技術(shù)教程優(yōu)化搜索引擎整站
  • 網(wǎng)站平臺(tái)推廣語錄軟文寫作技巧有哪些
  • 義烏網(wǎng)站建設(shè)公司三只松鼠搜索引擎推廣
  • 做高端生活方式的網(wǎng)站廣州網(wǎng)站優(yōu)化
  • 在愛學(xué)術(shù)網(wǎng)站做論文代寫百度云網(wǎng)盤資源搜索引擎入口
  • 盤錦做網(wǎng)站公司百度推廣登錄后臺(tái)登錄入口
  • 網(wǎng)站建設(shè)合同編號(hào)廣州網(wǎng)站優(yōu)化排名
  • 棗莊市住房和建設(shè)局網(wǎng)站學(xué)電商出來一般干什么工作
  • 什么是網(wǎng)站組件優(yōu)化服務(wù)公司
  • 網(wǎng)站的做網(wǎng)站公司免費(fèi)建立一個(gè)網(wǎng)站
  • 建站神器淄博搜索引擎優(yōu)化
  • 移動(dòng)網(wǎng)站開發(fā)實(shí)訓(xùn)報(bào)告泉州百度seo公司
  • 莆田網(wǎng)站建設(shè)五維網(wǎng)絡(luò)有限公司百度ai助手入口
  • 網(wǎng)站后臺(tái)開發(fā) 必備技能關(guān)鍵詞林俊杰百度云
  • 彈幕網(wǎng)站制作市場營銷策劃書
  • wordpress tag導(dǎo)入2022年seo最新優(yōu)化策略
  • vb2010做網(wǎng)站企業(yè)營銷網(wǎng)站建設(shè)系統(tǒng)
  • html網(wǎng)站開發(fā)工具下載北京網(wǎng)站優(yōu)化托管
  • 東莞專業(yè)網(wǎng)站建設(shè)公司站長工具ping
  • 河南做網(wǎng)站公司排名全國十大跨境電商公司排名
  • 在環(huán)評(píng)備案網(wǎng)站上做登記后會(huì)怎么樣6淘寶直通車
  • 做跨境的網(wǎng)站有哪些網(wǎng)絡(luò)口碑營銷案例
  • 如何做國外的網(wǎng)站網(wǎng)絡(luò)營銷八大工具
  • 直播營銷惠州seo推廣優(yōu)化
  • 哪些網(wǎng)站做財(cái)金的好seo網(wǎng)絡(luò)營銷技巧