/** * Gets the data within a channel. * * Body of output document takes the form: * * <code> * [{"object_type":"x","communication_key":"y","position":"99","data":{...},...] * </code> * * @param array $params The following keys are expected: * `array('channelset'=>'name of channelset','channel'=>'name of channel')` */ public function restGetChannelsetChannel($params) { $channelsetId = $this->getChannelSetId($params['channelset']); $userRec = $this->getUser($channelsetId); InstructionControl::setUserChannelset($userRec['id'], $channelsetId); $data = InstructionControl::getInstructionForChannel(InstructionControl::getChannelId($channelsetId, $params['channel'])); header('HTTP/1.1 200 OK'); echo json_encode(InstructionControl::generateReturnDocument('CHANNEL_DATA', array(), array(), array(), array('channel' => $params['channel']), $data)); return true; }
public function testGetUserByCommunicationKey() { $csid = InstructionControl::getChannelSetId(genSaneGuid()); $u = InstructionControl::getUser(null, $n); $u = InstructionControl::getUser($u['login_key'], $n); InstructionControl::setUserChannelset($u['id'], $csid); $v = InstructionControl::getUserByCommunicationKey($csid, $u['communication_key']); $this->assertEquals($u, $v); $w = InstructionControl::getUserByCommunicationKey($csid, genSaneGuid()); $this->assertNull($w); }