コード例 #1
0
ファイル: friends.model.php プロジェクト: hcopr/Hubbub
	function friend_request($toEntity, $msgtype = 'friend_request')
	{
    $fr = new HubbubMessage($msgtype);
    $fr->to($toEntity->ds);
    $fr->from(object('user')->entity);
    $res = $fr->sendToUrl($toEntity->ds['server']);
		return($res);
	}
コード例 #2
0
ファイル: hubbub2.php プロジェクト: hcopr/Hubbub
 function msg_trust_sendkey1()
 {
     // make a trust_sendkey1 message
     $msg = new HubbubMessage('trust_sendkey1');
     $msg->to($this->entity());
     $msg->data['author'] = $this->localEntity();
     $this->save();
     // make new key if there is none
     $this->ds['s_key_in'] = getDefault($this->ds['s_key_in'], randomHashId());
     if ($this->ds['s_url'] != '') {
         DB_UpdateField('servers', $this->ds['s_key'], 's_key_in', $this->ds['s_key_in']);
     }
     $msg->data['mykey'] = $this->ds['s_key_in'];
     // we need to save at this point because the other server will try to make a trust_sendkey2-request in the meantime
     // send message to other server
     $responseData = $msg->sendToUrl($this->ds['s_url']);
     if ($responseData['result'] == 'OK') {
         $this->ds['s_status'] = 'OK';
         $ret = result_ok();
     } else {
         $this->ds['s_status'] = 'fail';
         $this->ds['s_key_in'] = '';
         logError('notrace', '[OUT] trust_sendkey1 failed, server ' . $this->ds['s_url'] . ' says: ' . getDefault($responseData['reason'], $responseData['result']));
         $ret = result_fail('trust_sendkey1 failed: ' . getDefault($responseData['reason'], $responseData['result']));
     }
     return $ret;
 }