Environment:Tomcat 7Maven ProjectIDE is IDEA2017Project Function Description:Starting the project will launch a web-side websocket-client and a Java-emulated websocket-server.There is also a main class in the project, which is launched separately, simulating the launch of a Java-side
WebSocket Protocol IntroductionThe WebSocket protocol is a network protocol that allows two connected ends to have full-duplex message communication on a single TCP connection.In the WebSocket scenario, the connection is established in a way that interacts with HTTP and websocket endpoints. The connected party sends a
1. Work Flow(1) The Java server creates the WebSocket instance and maintains and waits in the Tomcat container.(2) A client WebSocket instance is created in the browser, then the server is connected and if the connection succeeds, the server triggers the OnOpen event, and the client triggers the OnOpen event.(3) The WebSocket
) (Session management)11. According to the Chinese characters to parse the whole spelling (pinyin) and the first letter (import Excel to the user table, based on the user's Chinese character name generation Pinyin user name) 12.app interface @ResponseBody(supports interaction with other language data) 13. Aurora Push (push to the app for instant messages, app does not start to receive)14. Interface (authentication, text, reply, etc.) remote control server restart, lock, other applications15.
I've been thinking about a problem lately: How does a server proactively send messages to a browser? The traditional web is a browser that actively sends requests to the server, and the server returns data to the browser after it receives the request. If you want to implement a server to proactively send messages to the browser, that is, the implementation of the Web version of instant communication should do? There seems to be no answer. Before the use of polling to implement pseudo-instant com
, increase system performance15.uploadify upload plugin, single, batch upload multi-threaded, with progress bar, asynchronous, image, video, other file formats can be uploaded16.tab label page function, tag free switch, not duplicate operation database17. Baidu Rich Text editor, can upload pictures18. Web crawler technology, can be based on the Web site to crawl pictures and page titles and other information (crawl a store image to save the server)19.java
(); ASec.getuserproperties (). put (HttpSession.class. GetName (), httpSession); at } -}Then add the Configurator configuration to the annotations @serverendpoint 1 @ServerEndpoint (value= "/websocket", Configurator=gethttpsessionconfigurator. Class)It is now possible to get to httpsession.However, if I do not log in, but need to temporarily login this situation? According to the above demo, you will find that there is no way to connect, has bee
Java front and back end implementation WebSocket message push (targeted push)
1, need to add a dependency package, in the Pom.xml file to add
2. Client code
Here I am in order to make HttpSession login is the same, so I made two pages, a login jump page, a link to websocket receive messages
A. Login page
B. Receiving a message push page
3, on t
Objective
HTML5 WebSocket realizes the two-way communication between the server and the browser, the bidirectional communication makes the server message push development simpler, the most common is the instant communication and the high demand for the real-time information. Most of the previous server message tweets used "polling" and "long Connection" technologies, both of which have considerable overhead and are not particularly high in real time.
= Logm
Anager.getlogger (); Private final set
Clustermessagingendpoint:websocket Endpoint
"1" We are concerned with the event of the cluster received from the WebSocket connection, which is handled with the server and client of WebSocket. After serializing the event object, it is passed directly in the WebSocket connection, so codec is the serialization
In a recent project, you need to use the Java websocket new features, so I learned that the technology is quite fun, and instantly know the Web page above the online customer service is how to do it.
First look at the picture:
Multi-client is implemented for real-time communication.
Look at the Code Project structure Chart: Very simple, 1 classes, 1 pages
Then look at the specific code
Look at th
1. Establish WebSocket connection (call OnOpen method)
1) Establish WebSocket connection
2) Add the current object to the collection (Note thread safety)
3) Broadcast messages
2. Disconnect the WS connection (the OnClose method is called when the WS connection is closed)3, point-to-point Send message implementation (Dictionary {USERID:WS Session})
1) Background receive messages
2) Poi
WebSocket API Introduction:First look at a simple JavaScript code that calls the WebSockets API.[JavaScript]View Plaincopy
var NBSP;WSNBSP;=NBSP; new websocket ("WS: //echo.websocket.org"); NBSP;NBSP;
NBSP;NBSP;
ws.onopen=function
NBSP;NBSP;
ws.onmessage=function
NBSP;NBSP;
ws.onclose=function
NBSP;NBSP;
Ws.onerror = function(evt) {console.log ("websocketerror!
Wbsocket Official agreement content: Http://datatracker.ietf.org/doc/rfc6455/?include_text=1
Connection Request Content:
get/http/1.1 Connection:upgrade host:127.0.0.1:8088 origin:null sec-websocket-extensions:x-webkit-deflate-frame sec-websocket-key:puvouwb7rel6z2avzbknfw== sec-websocket-version:13 Upgrade:websocket
When the server receives the request, it main
JAVA WebSocket Real-time message pushThe implementation steps are as follows:1. Get Goeasy Appkey.Register an account on the Goeasy website and create a new app. After the app is created, the system automatically generates two keys for the app, one that can be used for both receiving and pushing (supper key), and the other to receive (Subscriber key).2. The client subscribes to a channel.A. Introducing Goea
useful data, the server and the client also exchange a bunch of request headers, in response to the first thing, the efficiency of information exchange is not high. In fact, long polling is a pseudo-long connection, and it is still necessary to follow the rules of the HTTP connection: the client request-the server response-frees the connection and, by the way, exchanges some of the same useless information. (resulting in wasted bandwidth)WebSocket th
webchat chat Room
2018.02.26
Source Address has been posted Ah, leaving the mailbox as their own download
project address: Https://github.com/Amayadream/WebChat
2017.01.11 Update
-replace Oracle with MySQL
-organize the structure and remove unwanted code
I. Implementation effect (here the picture is compressed, you can right-click to view the picture)
Landing Page
Chat Room
Personal Settings
Avatar Modification
Log Listtwo. Source Code
Here is the direct and brutal to the source code b
information that the client browser needs to provide to the server side, the server side resolves the header information, generates a 16-bit security key and returns it to the client during the handshake, to indicate that the server has obtained the client's request and agrees to create a WebSocket connection. Once the connection is established, the client and server can transmit data in both directions through this channel.In the actual development
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.