2017-09-08 16:40:59 +02:00
|
|
|
import { SOCKET_STATE, SOCKET_UPDATE, SOCKET_URI } from '../actions/socket';
|
2017-09-07 11:35:15 +02:00
|
|
|
|
2017-09-08 06:55:47 +02:00
|
|
|
export default function socket(_state = {
|
|
|
|
state: SOCKET_STATE.DISCONNECTED,
|
2017-09-08 16:40:59 +02:00
|
|
|
reason: null,
|
2017-10-13 06:34:26 +02:00
|
|
|
uri: null,
|
|
|
|
password: null,
|
2017-09-08 06:55:47 +02:00
|
|
|
}, action) {
|
2017-09-08 16:40:59 +02:00
|
|
|
const { state, reason, uri } = action;
|
2017-09-07 11:35:15 +02:00
|
|
|
switch (action.type) {
|
2017-09-08 06:55:47 +02:00
|
|
|
case SOCKET_UPDATE:
|
|
|
|
return { ..._state, state, reason };
|
2017-09-08 16:40:59 +02:00
|
|
|
case SOCKET_URI:
|
2017-10-13 06:34:26 +02:00
|
|
|
return { ..._state, ...uri, };
|
2017-09-07 11:35:15 +02:00
|
|
|
default:
|
2017-09-08 06:55:47 +02:00
|
|
|
return _state;
|
2017-09-07 11:35:15 +02:00
|
|
|
}
|
|
|
|
}
|