how to use socket IO in kotlin?

前端 未结 4 1472
被撕碎了的回忆
被撕碎了的回忆 2020-12-21 00:07

I want to initialize socket IO in my kotlin app.

my problem is here :

    private var mSocket: Socket? = null
{
    try {
        mSocket = IO.socket         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 01:00

    The right syntax is below for anyone who is interested in the future

    private lateinit var mSocket:Socket
    
    fun socket(){
        try {
            mSocket=IO.socket("http://host:port")
        }
        catch(e: URISyntaxException){
            println("Exception"+e)
        }
    
    
    }
    

提交回复
热议问题