Wrote _wsOnMessage function