Beispiel #1
0
        public void GetData(Connection state, OJNList ojnlist)
        {
            OJN[] headers = ojnlist.GetHeaders();

            using (MemoryStream ms = new MemoryStream())
                using (BinaryWriter bw = new BinaryWriter(ms)) {
                    short length = (short)(6 + (headers.Length * 12) + 12);
                    bw.Write(length);
                    bw.Write(new byte[] { 0xBF, 0x0F });
                    bw.Write((short)ojnlist.Count);

                    foreach (OJN ojn in headers)
                    {
                        bw.Write((short)ojn.Id);
                        bw.Write((short)ojn.NoteCountEx);
                        bw.Write((short)ojn.NoteCountNx);
                        bw.Write((short)ojn.NoteCountHx);
                        bw.Write(new byte[4]);
                    }

                    bw.Write(new byte[12]);

                    state.Send(ms.ToArray());
                }
        }
Beispiel #2
0
        public void Stop()
        {
            m_server.Stop();
            m_server = null;
            m_list   = null;

            Log.Write("Server Shutdown!");
            Ready = false;
        }
Beispiel #3
0
        public void Intialize(ClientCheck config)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            try {
                Version = config.Version;

                m_list      = OJNListDecoder.Decode(AppDomain.CurrentDomain.BaseDirectory + $"\\Image\\{config.OJNList}");
                m_musiclist = new(AppDomain.CurrentDomain.BaseDirectory + $"\\Image\\{config.OJNList}");
                m_server    = new TCPServer(m_config.ServerPort);
                m_server.OnServerMessage += ServerMessage;
                m_server.Intialize();

                Ready = true;
            } catch (Exception e) {
                Log.Write("::Initialize -> {0}", e.Message);
                OnError?.Invoke(this, e);
            }
        }
Beispiel #4
0
        public static OJNList Decode(Stream stream, bool keepOpen = false, bool newFormat = false)
        {
            var headers = new OJNList();

            byte[] inputData = new byte[0];

            using (var reader = new BinaryReader(stream, Encoding.Unicode, keepOpen)) {
                stream.Seek(0, SeekOrigin.Begin);
                int songCount = reader.ReadInt32();

                headers.Version = newFormat ? FileFormat.New : FileFormat.Old; // (stream.Length > 4 + (songCount * 300) ? FileFormat.New : FileFormat.Old);
                var charset = headers.Version == FileFormat.New ? KoreanEncoding : ChineseEncoding;

                for (int i = 0; i < songCount; i++)
                {
                    headers.Add(OJNDecoder.Decode(reader.ReadBytes(300), Encoding.GetEncoding(charset)));
                }

                if (headers.Version == FileFormat.New)
                {
                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id   = reader.ReadInt32();
                        int val1 = reader.ReadInt32();
                        int val2 = reader.ReadInt32();
                        int val3 = reader.ReadInt32();
                    }

                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id    = reader.ReadInt32();
                        int state = reader.ReadInt32();
                        int val1  = reader.ReadInt32();
                        int val2  = reader.ReadInt32();
                        int val3  = reader.ReadInt32();
                    }

                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id   = reader.ReadInt32();
                        int val1 = reader.ReadInt32();
                        int val2 = reader.ReadInt32();
                        int val3 = reader.ReadInt32();
                    }

                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id   = reader.ReadInt32();
                        int val1 = reader.ReadInt32();
                        int val2 = reader.ReadInt32();
                    }

                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id   = reader.ReadInt32();
                        int val1 = reader.ReadInt32();
                    }

                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id   = reader.ReadInt32();
                        int val1 = reader.ReadInt32();
                        int val2 = reader.ReadInt32();
                    }

                    songCount = reader.ReadInt32();

                    songCount = reader.ReadInt32();
                    for (int i = 0; i < songCount; i++)
                    {
                        int id = reader.ReadInt32();
                        if (id > 0 && headers.Contains(id))
                        {
                            var header = headers[id];
                            header.KeyMode = reader.ReadByte();
                            reader.ReadInt16();
                            reader.ReadByte();
                        }
                        else
                        {
                            reader.ReadInt32();
                        }
                    }
                }

                return(headers);
            }
        }
Beispiel #5
0
 public void LoadOJNlist()
 {
     ojnlist = OJNListDecoder.Decode(AppDomain.CurrentDomain.BaseDirectory + @"\Image\OJNList.dat", true);
 }