//go:build windows

package yu_hpsocket

import (
	yu_strings "gogs.qqck.cn/s/tools/strings"
	"syscall"
)

func init() {
	server_http_callback_OnMessageBegin_ptr = syscall.NewCallback(server_http_callback_OnMessageBegin)
	server_http_callback_OnRequestLine_ptr = syscall.NewCallback(server_http_callback_OnRequestLine)
	server_http_callback_OnHeader_ptr = syscall.NewCallback(server_http_callback_OnHeader)
	server_http_callback_OnHeadersComplete_ptr = syscall.NewCallback(server_http_callback_OnHeadersComplete)
	server_http_callback_OnBody_ptr = syscall.NewCallback(server_http_callback_OnBody)
	server_http_callback_OnChunkHeader_ptr = syscall.NewCallback(server_http_callback_OnChunkHeader)
	server_http_callback_OnChunkComplete_ptr = syscall.NewCallback(server_http_callback_OnChunkComplete)
	server_http_callback_OnMessageComplete_ptr = syscall.NewCallback(server_http_callback_OnMessageComplete)
	server_http_callback_OnUpgrade_ptr = syscall.NewCallback(server_http_callback_OnUpgrade)
	server_http_callback_OnParseError_ptr = syscall.NewCallback(server_http_callback_OnParseError)
	server_http_callback_OnWSMessageHeader_ptr = syscall.NewCallback(server_http_callback_OnWSMessageHeader)
	server_http_callback_OnWSMessageBody_ptr = syscall.NewCallback(server_http_callback_OnWSMessageBody)
	server_http_callback_OnWSMessageComplete_ptr = syscall.NewCallback(server_http_callback_OnWSMessageComplete)
}

var (
	server_http_callback_OnMessageBegin_ptr      uintptr
	server_http_callback_OnRequestLine_ptr       uintptr
	server_http_callback_OnHeader_ptr            uintptr
	server_http_callback_OnHeadersComplete_ptr   uintptr
	server_http_callback_OnBody_ptr              uintptr
	server_http_callback_OnChunkHeader_ptr       uintptr
	server_http_callback_OnChunkComplete_ptr     uintptr
	server_http_callback_OnMessageComplete_ptr   uintptr
	server_http_callback_OnUpgrade_ptr           uintptr
	server_http_callback_OnParseError_ptr        uintptr
	server_http_callback_OnWSMessageHeader_ptr   uintptr
	server_http_callback_OnWSMessageBody_ptr     uintptr
	server_http_callback_OnWSMessageComplete_ptr uintptr
)

func server_http_callback_OnMessageBegin(Sender, ConnID uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onMessageBegin(t, Sender, ConnID)
	}
	return HPR_OK
}

func server_http_callback_OnRequestLine(Sender, ConnID, Method, Url uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onRequestLine(t, Sender, ConnID, yu_strings.GbkPtrToUtf8(Method), yu_strings.GbkPtrToUtf8(Url))
	}
	return HPR_OK
}

func server_http_callback_OnHeader(Sender, ConnID, Name, Value uintptr) HPR {
	// switch j_item := _server_on_get(Sender); j_item._type {
	// case _server_type_HttpServer:
	// 	t := j_item.t.(*HttpServer)
	// 	return t.onHeader(t, Sender, ConnID, yu_strings.GbkPtrToUtf8(Name), yu_strings.GbkPtrToUtf8(Value))
	// }
	return HPR_OK
}

func server_http_callback_OnHeadersComplete(Sender, ConnID uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onHeadersComplete(t, Sender, ConnID)
	}
	return HPR_OK
}

func server_http_callback_OnBody(Sender, ConnID, Data uintptr, Length uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onBody(t, Sender, ConnID, Data, Length)
	}
	return HPR_OK
}

func server_http_callback_OnChunkHeader(Sender, ConnID uintptr, Length uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onChunkHeader(t, Sender, ConnID, Length)
	}
	return HPR_OK
}

func server_http_callback_OnChunkComplete(Sender, ConnID uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onChunkComplete(t, Sender, ConnID)
	}
	return HPR_OK
}

func server_http_callback_OnMessageComplete(Sender, ConnID uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onMessageComplete(t, Sender, ConnID)
	}
	return HPR_OK
}

func server_http_callback_OnUpgrade(Sender, ConnID uintptr, UpgradeType HUT) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onUpgrade(t, Sender, ConnID, UpgradeType)
	}
	return HPR_OK
}

func server_http_callback_OnParseError(Sender, ConnID uintptr, ErrorCode int, ErrorDesc uintptr) HPR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onParseError(t, Sender, ConnID, ErrorCode, yu_strings.GbkPtrToUtf8(ErrorDesc))
	}
	return HPR_OK
}

func server_http_callback_OnWSMessageBody(Sender, ConnID, Data uintptr, Length uintptr) HR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onWSMessageBody(t, Sender, ConnID, Data, Length)
	}
	return HR_OK
}

func server_http_callback_OnWSMessageComplete(Sender, ConnID uintptr) HR {
	switch j_item := _server_on_get(Sender); j_item._type {
	case _server_type_HttpServer:
		t := j_item.t.(*HttpServer)
		return t.onWSMessageComplete(t, Sender, ConnID)
	}
	return HR_OK
}
