Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react'
- let io = require('socket.io-client')
- class Server {
- constructor() {
- this.socket = null
- this.host = 'http://localhost'
- this.port = 5001
- }
- connect = () => {
- return new Promise(resolve => {
- this.socket = io(this.host+':'+this.port)
- this.socket.on('connect', () => {
- resolve()
- })
- })
- }
- socket() {
- return this.socket
- }
- }
- export default Server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement