Skip to content

jtsinghua/pushmessage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pushmessage

推送消息

  • 使用的是 Websocket技术

  • 客户端使用指南

    fun main(args: Array<String>){
    
      val uri = URI("ws://localhost:8080/pushmsg/linkpoint")
      val webSocket = WebSocket(uri)
    
      webSocket.eventHandler = object : WebSocketEventHandler {
          override fun onOpen() {
              println("建立连接")
              webSocket.send("{userId: '40009'}")
          }
    
          override fun onMessage(message: WebSocketMessage?) {
              println("收到消息:" + message!!.text)
          }
    
          override fun onError(exception: IOException?) {
              println("发生错误:" + exception!!.message)
          }
    
          override fun onClose() {
              println("关闭连接")
          }
    
          override fun onPong() {
              println("pong...")
          }
    
          override fun onPing() {
              println("ping...")
          }
    
      }
    
      webSocket.connect()
    
    }
    
  • 推送消息使用springmvc

    http://localhost:8080/pushMessage/sendMessage

    json: { userId: '40009', msg: '这就是测试啊!!' }

About

使用spring Websocket 实现消息推送

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published