Esempio n. 1
0
        protected override bool preProcessData(object package, Socket client)
        {
            bool l = base.preProcessData(package, client);
            if (l) {
                if (package is Profile) {
                    this.opponentProfile = (Profile)package;
                    l = false;

                    if (isClient()) {
                        send(profile);
                    } else {
                        send(new TimePack(DateTime.Now.Ticks));
                    }
                } else if (package is TimePack) {
                    l = false;
                    if (isClient()) {
                        send(package);
                    } else {
                        ping = (DateTime.Now.Ticks - ((TimePack)package).Time) / 2;
                        send("START");
                    }
                }

            }
            return l;
        }
 public ProfileWindow(Profile profile)
 {
     _profile = profile;
     InitializeComponent();
     txtUserName.Text = _profile.Username;
     imgAvatar.Source = _profile.Avatar;
 }
Esempio n. 3
0
        public LFNet(Profile prof)
            : base()
        {
            profile = prof;
            opponentProfile = null;

            this.NetClientEvent += LFNet_NetClientEvent;
        }
Esempio n. 4
0
 public void initialize(UniversalLobby.model.LFNet network, UniversalLobby.model.Profile profile)
 {
     replay = "None";
     Network = network;
     MyProfile = profile;
     OpponentProfile = Network.getOpponentProfile();
     Refresher = new DispatcherTimer();
     Refresher.Interval = new TimeSpan(100);
     Refresher.Tick += new EventHandler(Refresher_Tick);
     CountDown = new DispatcherTimer();
     CountDown.Interval = new TimeSpan(10000000);
     CountDown.Tick += new EventHandler(CountDown_Tick);
     if (MyProfile.Username == null)
     {
         playerNamelb.Content = "Me";
     }
     else
     {
         playerNamelb.Content = MyProfile.Username;
     }
     if (OpponentProfile.Username == null)
     {
         opponentNamelb.Content = "Opponent";
     }
     else
     {
         opponentNamelb.Content = OpponentProfile.Username;
     }
     if (MyProfile.Avatar != null)
     {
         ImgMyProfile.Source = MyProfile.Avatar;
     }
     if (OpponentProfile.Avatar != null)
     {
         ImgOpponentProfile.Source = OpponentProfile.Avatar;
     }
 }
Esempio n. 5
0
        void LFNet_NetClientEvent(object sender, UniversalNetwork.NetClientEvent e)
        {
            if (e.ev == UniversalNetwork.ClientEventType.connected) {
                if (getClientNames().Length > 1) {
                    kick(e.username);
                    return;
                }

                send(profile);
            } else if (e.ev == UniversalNetwork.ClientEventType.disconnected) {
                if (getClientNames().Length == 0) {
                    opponentProfile = null;
                }
            }
        }
Esempio n. 6
0
 public override void disconnect()
 {
     base.disconnect();
     opponentProfile = null;
 }
Esempio n. 7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _profile = new Profile("", null);
            ProfileWindow profile = new ProfileWindow(_profile);
            profile.ShowDialog();

            _lfnet = new LFNet(_profile);
            _lfnet.NetClientEvent += NetClientEventHandler;
            _lfnet.NetError += NetCoreEventHandler;
            _lfnet.ReceiveObservers += NetPackageReceiveHandler;
        }