| 143 | } |
| 144 | |
| 145 | int Emotibit::release_session () |
| 146 | { |
| 147 | if (initialized) |
| 148 | { |
| 149 | if (keep_alive) |
| 150 | { |
| 151 | stop_stream (); |
| 152 | } |
| 153 | initialized = false; |
| 154 | connection_thread.join (); |
| 155 | free_packages (); |
| 156 | send_control_msg (EMOTIBIT_DISCONNECT); |
| 157 | if (data_socket) |
| 158 | { |
| 159 | data_socket->close (); |
| 160 | delete data_socket; |
| 161 | data_socket = NULL; |
| 162 | } |
| 163 | if (control_socket) |
| 164 | { |
| 165 | control_socket->close (); |
| 166 | delete control_socket; |
| 167 | control_socket = NULL; |
| 168 | } |
| 169 | if (adv_socket) |
| 170 | { |
| 171 | adv_socket->close (); |
| 172 | delete adv_socket; |
| 173 | adv_socket = NULL; |
| 174 | } |
| 175 | control_port = -1; |
| 176 | data_port = -1; |
| 177 | } |
| 178 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 179 | } |
| 180 | |
| 181 | void Emotibit::read_thread () |
| 182 | { |
nothing calls this directly
no test coverage detected