Advertisement
benshepherd

Untitled

Aug 21st, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react'
  2. let io = require('socket.io-client')
  3.  
  4. class Server  {
  5.     constructor() {
  6.         this.socket = null
  7.         this.host = 'http://localhost'
  8.         this.port = 5001        
  9.     }
  10.  
  11.     connect = () => {
  12.         return new Promise(resolve => {
  13.             this.socket = io(this.host+':'+this.port)
  14.             this.socket.on('connect', () => {
  15.                 resolve()
  16.             })
  17.         })
  18.        
  19.     }
  20.  
  21.     socket() {
  22.         return this.socket
  23.     }
  24. }
  25.  
  26. export default Server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement