/*
 Copyright 2008 Peter Lawrey

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
package org.freshvanilla.net;

import org.freshvanilla.utils.Callback;
import org.freshvanilla.utils.SimpleResource;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;

public interface DataSocket extends SimpleResource {
    public static final int DEFAULT_MAXIMUM_MESSAGE_SIZE = 1024 * 1024;
    boolean DEBUG = Boolean.getBoolean("org.freshvanilla.net.datasocket.debug");

    public InetSocketAddress getAddress();

    public WireFormat wireFormat();

    public ByteBuffer writeBuffer();

    public long microTimestamp();

    public ByteBuffer read() throws IOException;

    public void flush() throws IOException;

    public void setReader(Callback<DataSocket> reader);

    public ConcurrentMap<Long, Callback> callbackMap();

    public Map<String, Object> getOtherHeader();

    public void timedCheck(long timeMS);
}
