Subversion Repositories HomeAutomation

Rev

Rev 1953 | Rev 2294 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1953 Rev 1954
Line 78... Line 78...
78
      }
78
      }
79
    }
79
    }
80
   
80
   
81
  }, function(socket_id, state)
81
  }, function(socket_id, state)
82
  {
82
  {
83
    Log(state);
-
 
84
   
-
 
85
    if (state == 0) // Connected
83
    if (state == 0) // Connected
86
    {
84
    {
-
 
85
      Log("Got connect on socket id " + socket_id);
-
 
86
     
87
      for (var n = 0; n < Xbmc_Susbscribers.length; n++)
87
      for (var n = 0; n < Xbmc_Susbscribers.length; n++)
88
      {
88
      {
89
        Xbmc_Susbscribers[n]("connected", socket_id);
89
        Xbmc_Susbscribers[n]("connected", socket_id);
90
      }
90
      }
91
    }
91
    }
92
    else if (state == 1) // Disconnected
92
    else if (state == 1) // Disconnected
93
    {
93
    {
94
      for (var n = 0; n < Mbb_Susbscribers.length; n++)
-
 
95
      {
-
 
96
        Xbmc_Susbscribers[n]("disconnected", socket_id);
94
      Log("Got disconnect on socket id " + socket_id);
97
       
95
     
98
        if (socket_id == Xbmc_Socket_Id)
96
      if (socket_id == Xbmc_Socket_Id)
99
        {
97
      {
100
          Xbmc_Socket_Id = null;
98
        Xbmc_Socket_Id = null;
101
        }
99
      }
-
 
100
     
-
 
101
      for (var n = 0; n < Mbb_Susbscribers.length; n++)
-
 
102
      {
-
 
103
        Xbmc_Susbscribers[n]("disconnected", socket_id);
102
      }
104
      }
103
    }
105
    }
104
  });
106
  });
105
 
107
 
106
  if (Xbmc_Socket_Id != 0)
108
  if (Xbmc_Socket_Id != 0)
107
  {
109
  {
108
    Log("Connected to XBMC at " + host + ":" + port + " successfully!");
110
    Log("Connected to XBMC at " + host + ":" + port + " successfully!");
109
    return true;
111
    return true;
110
  }
112
  }
-
 
113
 
-
 
114
  Log("Failed to connect to XBMC at " + host + ":" + port + "!");
111
 
115
 
112
  Xbmc_Socket_Id = null;
116
  Xbmc_Socket_Id = null;
113
  return false;
117
  return false;
114
}
118
}
115
Console_RegisterCommand(Xbmc_Connect);
119
Console_RegisterCommand(Xbmc_Connect);