Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static byte[] SerializeMessage(SerializedMessage networkMessage, ChicasInternalEventType eventType = ChicasInternalEventType.Data)
        {
            if (networkMessage == null)
            {
                return(null);
            }

            byte[] data;
            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, networkMessage);
                data = ms.ToArray();
            }

            return(ChicasNetworkingUtility.InsertInitialByteInArray((byte)eventType, data));
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static byte[] SerializeText(string text, ChicasInternalEventType eventType = ChicasInternalEventType.Data)
        {
            var byteArray = Encoding.UTF8.GetBytes(text);

            return(ChicasNetworkingUtility.InsertInitialByteInArray((byte)eventType, byteArray));
        }