Beispiel #1
0
Datei: key.c Projekt: GDXN/oosmos
static void StateMachine(void * pObject)
{
  key     * pKey = (key *) pObject;
  eStates   KeyState;

  switch (pKey->m_State) {
    case Up_State:
      if (!IsMyChar(pKey, &KeyState))
        return;

      if (KeyState == Down_State) {
        printf("key: ****************** %c pressed\n", pKey->m_Char);
        oosmos_SubscriberListNotify(pKey->m_PressedEvent);
        pKey->m_State = Down_State;
      }

      break;

    case Down_State:
      if (!IsMyChar(pKey, &KeyState))
        return;

      if (KeyState == Up_State) {
        printf("key: ****************** %c released\n", pKey->m_Char);
        oosmos_SubscriberListNotify(pKey->m_ReleasedEvent);
        pKey->m_State = Up_State;
      }

      break;
  }
}
Beispiel #2
0
static bool CheckReceiveError(sock * pSock, recvsize_t BytesReceived)
{
  if (BytesReceived == -1) {
    const int Error = sockGetLastError();

    if (Error == sockEWOULDBLOCK)
      return false;

    oosmos_SubscriberListNotify(pSock->m_ClosedEvent);
    pSock->m_Closed = true;
    return true;
  }
  else if (BytesReceived == 0) {
    oosmos_SubscriberListNotify(pSock->m_ClosedEvent);
    pSock->m_Closed = true;
    return true;
  }

  return false;
}
Beispiel #3
0
static bool CheckSendError(sock * pSock, sendsize_t BytesSent)
{
  if (BytesSent <= 0) {
    const int Error = sockGetLastError();

    if (Error == sockEWOULDBLOCK)
      return false;

    oosmos_SubscriberListNotify(pSock->m_ClosedEvent);
    pSock->m_Closed = true;
    return true;
  }

  return false;
}