This code works, but I don't like that it has a global variable. I'd like to make the webSocket variable a private variable of this class.
#ifndef _BRAINSTEM_H_
#define _BRAINSTEM_H_
#include <Arduino.h>
#include <WebSocketsServer.h>
#include <Hash.h>
WebSocketsServer webSocket = WebSocketsServer(81);
class Brainstem{
public:
void begin();
private:
};
void Brainstem::begin(){
}
This *seems* like it should work and it feels like it's more encapsulated as a private variable. But I'm getting compiling errors.
#ifndef _BRAINSTEM_H_
#define _BRAINSTEM_H_
#include <Arduino.h>
#include <WebSocketsServer.h>
#include <Hash.h>
class Brainstem{
public:
void begin();
private:
WebSocketsServer webSocket;
};
void Brainstem::begin(){
webSocket = WebSocketsServer(81);
}
I'm not sure if all of this is wrong-headed thinking for this particular library. Maybe it's not designed to work like this. Is there a glaring flaw in my syntax or am I just thinking about this library wrong?