Skip to content

Commit

Permalink
Removed duplicate function of CustomSocket. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lem()nTea_ committed Nov 29, 2014
1 parent 7ab4d5d commit 2cbf683
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions plugin/src/ifteam/CustomPacket/MainLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,51 +50,6 @@ public function getDefaultPort() {
return $this->option["port"];
}

/**
* ReceivePacket and callEvent ReceivePacketEvent
* or ReceiveJSONPacketEvent (is_numeric check)
*
* @param int|string $data
* @param int $ip
* @param int $port
*
*/
public function receivePacket($data, $ip, $port) {
if(is_numeric($data)){
$event = new ReceivePacketEvent($data, $ip, $port);
$this->getServer()->getPluginManager()->callEvent($event);
}else{
$event = new ReceiveJSONPacketEvent(JSON_Decode($data), $ip, $port);
$this->getServer()->getPluginManager()->callEvent($event);
}
}
/**
* SendPacket and callEvent SendPacketEvent
* or SendJSONPacketEvent (is_numeric check)
*
* @param int|string $packet
* @param string $ip
* @param int $port
*
*/
public static function sendPacket($packet, $ip, $port) {
if(is_numeric($packet)){
$event = new SendPacketEvent($packet, $ip, $port);
$this->getServer ()->getPluginManager ()->callEvent ($event);
if(!$event->isCancelled()){
$packet = $event->getPacket();
$this->socket->writePacket($packet, $ip, $port);
}
}else{
$event = new SendJSONPacketEvent($this, $packet, $ip, $port);
$this->getServer()->getPluginManager()->callEvent($event);
if(!$event->isCancelled()){
$packet = JSON_Encode($event->getPacket());
$this->socket->writePacket($packet, $ip, $port);
}
}
}

public function callEvent($type, array $data){
switch($type){
case 'recv':
Expand Down

0 comments on commit 2cbf683

Please sign in to comment.