private IgorrMessage NewMessage(MessageTypes type, NetOutgoingMessage outgoing) { IgorrMessage message = null; switch (type) { case MessageTypes.Chat: message = new Messages.ChatMessage(outgoing, _timeStamp); break; case MessageTypes.Position: message = new Messages.PositionMessage(outgoing, _timeStamp); break; case MessageTypes.Leave: message = new Messages.LeaveMessage(outgoing, _timeStamp); break; case MessageTypes.Join: message = new Messages.JoinMessage(outgoing, _timeStamp); break; case MessageTypes.Spawn: message = new Messages.SpawnMessage(outgoing, _timeStamp); break; case MessageTypes.SpawnAttack: message = new Messages.SpawnAttackMessage(outgoing, _timeStamp); break; case MessageTypes.AssignPlayer: message = new Messages.AssignPlayerMessage(outgoing, _timeStamp); break; case MessageTypes.DeSpawn: message = new Messages.DeSpawnMessage(outgoing, _timeStamp); break; case MessageTypes.Pickup: message = new Messages.PickupMessage(outgoing, _timeStamp); break; case MessageTypes.Kill: message = new Messages.KillMessage(outgoing, _timeStamp); break; case MessageTypes.Damage: message = new Messages.DamageMessage(outgoing, _timeStamp); break; case MessageTypes.Attack: message = new Messages.AttackMessage(outgoing, _timeStamp); break; case MessageTypes.SetAnimation: message = new Messages.SetAnimationMessage(outgoing, _timeStamp); break; case MessageTypes.ChangeTile: message = new Messages.ChangeTileMessage(outgoing, _timeStamp); break; case MessageTypes.ChangeMap: message = new Messages.ChangeMapMessage(outgoing, _timeStamp); break; case MessageTypes.Container: message = new Messages.ContainerMessage(outgoing, _timeStamp); break; case MessageTypes.Play: message = new Messages.PlayMessage(outgoing, _timeStamp); break; case MessageTypes.SetGlow: message = new Messages.SetGlowMessage(outgoing, _timeStamp); break; case MessageTypes.Shadow: message = new Messages.ShadowMessage(outgoing, _timeStamp); break; case MessageTypes.SetHP: message = new Messages.SetPlayerStatusMessage(outgoing, _timeStamp); break; case MessageTypes.PlayerInfo: message = new Messages.PlayerInfoMessage(outgoing, _timeStamp); break; case MessageTypes.ExpMessage: message = new Messages.ExpMessage(outgoing, _timeStamp); break; case MessageTypes.Knockback: message = new Messages.KnockbackMessage(outgoing, _timeStamp); break; case MessageTypes.ObjectInfo: message = new Messages.ObjectInfoMessage(outgoing, _timeStamp); break; case MessageTypes.Interact: message = new Messages.InteractMessage(outgoing, _timeStamp); break; case MessageTypes.DoEffect: message = new Messages.DoEffectMessage(outgoing, _timeStamp); break; case MessageTypes.MoveItem: message = new Messages.MoveItemMessage(outgoing, _timeStamp); break; case MessageTypes.BodyConfiguration: message = new Messages.BodyConfigurationMessage(outgoing, _timeStamp); break; case MessageTypes.AttachAnimation: message = new Messages.AttachAnimationMessage(outgoing, _timeStamp); break; case MessageTypes.Stun: message = new Messages.StunMessage(outgoing, _timeStamp); break; } return message; }
public void FlushContainer(NetConnection target, int channel) { //Console.WriteLine("Sending Container to: " + target.ToString()); if (target == null &&_allcontainer!=null) { _allcontainer.Encode(); if (_connection is NetServer && _connection.ConnectionsCount>0) (_connection as NetServer).SendToAll(_allcontainer.GetMessage(), null,NetDeliveryMethod.ReliableOrdered,channel); //Console.WriteLine(_allcontainer.GetMessage().LengthBytes); _allcontainer = null; } else if (target != null && _containers.ContainsKey(target)) { _containers[target].Encode(); _connection.SendMessage(_containers[target].GetMessage(), target, NetDeliveryMethod.ReliableOrdered, channel); //Console.WriteLine("Sending Container Message: " + _containers[target].ReReadType.ToString() + " " + _containers[target].outgoing.ToString()+ " " +target.RemoteEndpoint.ToString()); //Console.WriteLine(target.Status.ToString()); for (int x = 0; x < _containers[target].Messages.Count; x++) { // Console.WriteLine("\t\t" + _containers[target].Messages[x].MessageType.ToString()); } _containers.Remove(target); } else if (target != null) { Console.WriteLine("ERROR: could not send container message to: " + target.ToString()); } }
public IgorrMessage GetContainerMessage(MessageTypes type, NetConnection target) { if (target == null) { if(_allcontainer==null) _allcontainer = (Messages.ContainerMessage)NewMessage(MessageTypes.Container); return NewMessage(type, _allcontainer.outgoing); } else if (_containers.ContainsKey(target)) return NewMessage(type, _containers[target].outgoing); else { Messages.ContainerMessage ctm = (Messages.ContainerMessage)NewMessage(MessageTypes.Container); _containers.Add(target, ctm); return NewMessage(type, _containers[target].outgoing); } }
public static IgorrMessage DecodeMessage(IgorrMessage m) { IgorrMessage message = null; switch (m.MessageType) { case MessageTypes.Chat: message = new Messages.ChatMessage(m); break; case MessageTypes.Position: message = new Messages.PositionMessage(m); break; case MessageTypes.Leave: message = new Messages.LeaveMessage(m); break; case MessageTypes.Join: message = new Messages.JoinMessage(m); break; case MessageTypes.Spawn: message = new Messages.SpawnMessage(m); break; case MessageTypes.SpawnAttack: message = new Messages.SpawnAttackMessage(m); break; case MessageTypes.AssignPlayer: message = new Messages.AssignPlayerMessage(m); break; case MessageTypes.DeSpawn: message = new Messages.DeSpawnMessage(m); break; case MessageTypes.Pickup: message = new Messages.PickupMessage(m); break; case MessageTypes.Kill: message = new Messages.KillMessage(m); break; case MessageTypes.Damage: message = new Messages.DamageMessage(m); break; case MessageTypes.Attack: message = new Messages.AttackMessage(m); break; case MessageTypes.SetAnimation: message = new Messages.SetAnimationMessage(m); break; case MessageTypes.ChangeTile: message = new Messages.ChangeTileMessage(m); break; case MessageTypes.ChangeMap: message = new Messages.ChangeMapMessage(m); break; case MessageTypes.Container: message = new Messages.ContainerMessage(m); break; case MessageTypes.Play: message = new Messages.PlayMessage(m); break; case MessageTypes.SetGlow: message = new Messages.SetGlowMessage(m); break; case MessageTypes.Shadow: message = new Messages.ShadowMessage(m); break; case MessageTypes.SetHP: message = new Messages.SetPlayerStatusMessage(m); break; case MessageTypes.PlayerInfo: message = new Messages.PlayerInfoMessage(m); break; case MessageTypes.ExpMessage: message = new Messages.ExpMessage(m); break; case MessageTypes.Knockback: message = new Messages.KnockbackMessage(m); break; case MessageTypes.ObjectInfo: message = new Messages.ObjectInfoMessage(m); break; case MessageTypes.Interact: message = new Messages.InteractMessage(m); break; case MessageTypes.DoEffect: message = new Messages.DoEffectMessage(m); break; case MessageTypes.BodyConfiguration: message = new Messages.BodyConfigurationMessage(m); break; case MessageTypes.MoveItem: message = new Messages.MoveItemMessage(m); break; case MessageTypes.AttachAnimation: message = new Messages.AttachAnimationMessage(m); break; case MessageTypes.Stun: message = new Messages.StunMessage(m); break; } return message; }