<?php

namespace SpaceDrift;


class Dispatcher{
    private $list;

    function __construct(){}

    function addMessage(Message $message){
        $this->list[] = $message;
    }

    function toJSON(){
        return json_encode($this->list);
    }

    function count(){
        return count($this->list);
    }
}

class Message {
    public $type, $from, $to, $body;

    function  __construct($type = null, $state = null, $from = 0, $to = 0, $body = ""){
        if($type){
            $this->type = $type;
            $this->state = $state;
            $this->from = $from;
            $this->to = $to;
            $this->body = $body;
        }
    }
} 