socketIO.js 1.35 KB
Newer Older
Giang Tran committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
import io from 'socket.io-client/dist/socket.io';
import {NetworkSetting} from './Setting';

export const connectSocket = () => {
  const socket = io(NetworkSetting.SOCKETCHAT, {
    jsonp: false,
    // timeout: 10000,
    // // transports: ['websocket'],
    // autoConnect: false,
    agent: '-',
    // path: '/', // Whatever your path is
    pfx: '-',
    // // key: token, // Using token-based auth.
    // // passphrase: cookie, // Using cookie auth.
    reconnection: true,
    'force new connection': true,
    transports: ['websocket', 'polling'],
    cert: '-',
    ca: '-',
    ciphers: '-',
    rejectUnauthorized: '-',
    perMessageDeflate: '-',
  });
  return socket;
};

export const SOCKET_EVENTS = {
  EVENT: 'event',
  CONNECTION: 'connection',
};

export const EVENT_STATUS = {
  UNKNOW: 0,
  ACTIVE: 1,
  INACTIVE: 2,
};

export const ROOMS = {
  COMMENT: 'COMMENT_',
};

export const NAMESPACE = {
  COMMENT: '/comments',
  HOME: '/homes',
  SHARE: '/share',
  REVIEW_DETAIL: '/review_detail',
  COMMENT_REVIEW_DETAIL: '/comment_review_detail',
  PROFILE: '/profile',
  REPLY_COMMENT: '/reply-comments',
  WALLET: '/wallet',
  PRIVATE_CHAT: '/private_chat',
  THREAD_CHAT: '/thread_chat',
};

export const MESSAGE_TYPE = {
  TEXT: 1,
  IMAGE: 2,
  LOCATION: 3,
  ALERT: 4,
};

export const MESSAGE_STATUS = {
  SENT: 1,
  PENDING: 2,
  RECEIVER: 3,
  READ: 4,
};