Example #1
0
 private void ChangeNextItemOverride(PlaylistItem newOverride, HaProtoImpl.InjectionType? newType=null)
 {
     if (newType.HasValue)
         mainForm.DataSource.NextItemOverrideAction = newType.Value;
     mainForm.DataSource.NextItemOverride = newOverride;
     mainForm.BroadcastMessage(HaProtoImpl.Opcode.INJECT, new HaProtoImpl.INJECT() {
         uid = newOverride != null ? newOverride.UID : -1,
         type =newType.HasValue ? newType.Value : HaProtoImpl.InjectionType.INJECT_SONG
     });
 }
Example #2
0
 public void BroadcastMessage(HaProtoImpl.Opcode type, HaProtoImpl.HaProtoPacket packet, Client exempt = null)
 {
     byte[] data = packet.Build();
     lock (clients)
     {
         for (int i = 0; i < clients.Count; i++)
         {
             Client c = clients[i];
             if (c == exempt)
                 continue;
             HaProtoImpl.Send(c.Socket, type, data);
         }
     }
 }
Example #3
0
 public static void Send(Socket s, Opcode type, HaProtoImpl.HaProtoPacket x)
 {
     Send(s, type, x.Build());
 }
Example #4
0
 public static HaProtoImpl.HaProtoPacket ApplyPacketToDatabase(HaProtoImpl.Opcode op, byte[] data, ServerDataSource dataSource, out bool result)
 {
     HaProtoPacket packet;
     switch (op)
     {
         case HaProtoImpl.Opcode.ADD:
             packet = HaProtoImpl.ADD.Parse(data);
             break;
         case HaProtoImpl.Opcode.REMOVE:
             packet = HaProtoImpl.REMOVE.Parse(data);
             break;
         case HaProtoImpl.Opcode.CLEAR:
             packet = HaProtoImpl.CLEAR.Parse(data);
             break;
         case HaProtoImpl.Opcode.SETSONG:
             packet = HaProtoImpl.SETSONG.Parse(data);
             break;
         case HaProtoImpl.Opcode.SKIP:
             packet = HaProtoImpl.SKIP.Parse(data);
             break;
         case HaProtoImpl.Opcode.ADDPL:
             packet = HaProtoImpl.ADDPL.Parse(data);
             break;
         case HaProtoImpl.Opcode.DELPL:
             packet = HaProtoImpl.DELPL.Parse(data);
             break;
         case HaProtoImpl.Opcode.RENPL:
             packet = HaProtoImpl.RENPL.Parse(data);
             break;
         case HaProtoImpl.Opcode.SETMOVE:
             packet = HaProtoImpl.SETMOVE.Parse(data);
             break;
         case HaProtoImpl.Opcode.REORDER:
             packet = HaProtoImpl.REORDER.Parse(data);
             break;
         case HaProtoImpl.Opcode.INJECT:
             packet = HaProtoImpl.INJECT.Parse(data);
             break;
         case HaProtoImpl.Opcode.LIBRARY_ADD:
             packet = HaProtoImpl.LIBRARY_ADD.Parse(data);
             break;
         case HaProtoImpl.Opcode.LIBRARY_REMOVE:
             packet = HaProtoImpl.LIBRARY_REMOVE.Parse(data);
             break;
         case HaProtoImpl.Opcode.LIBRARY_RESET:
             packet = HaProtoImpl.LIBRARY_RESET.Parse(data);
             break;
         default:
             throw new NotImplementedException();
     }
     result = packet.ApplyToDatabase(dataSource);
     return packet;
 }
Example #5
0
 private void ExecutePacketAndBroadcast(HaProtoImpl.Opcode op, HaProtoImpl.HaProtoPacket packet)
 {
     bool announceIndexChange;
     lock (dataSource.Lock)
     {
         announceIndexChange = packet.ApplyToDatabase(dataSource);
     }
     if (announceIndexChange)
     {
         AnnounceIndexChange();
     }
     BroadcastMessage(op, packet);
 }
Example #6
0
 public MoveType(string name, HaProtoImpl.MoveType type)
 {
     this.Name = name;
     this.Type = type;
 }